Uğur UMUTLUOĞLU
Web Technologies, Microsoft and .NET Technologies

Microsoft Products' Codename History

Monday, 22 December 2008 22:37 by ugur

As you know, Microsoft announces a lot of products that are in beta phase with specific codenames and makes us to warm towards future improvements earlier. If I want from you to list some of the codenames, which ones do you think of first? Whidbey, Orcas, Yukon, Longhorn etc...

When I examined a link that I came across in Wikipedia, I realized that Microsoft has been using codename as an important standard since years. You can both scan codename history and see the point where we are while time travelling from this page. Where is Windows 3.1, where is Windows Vista

Tags:  
Categories:   News&Announcements
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Showing XPS Documents with DocumentViewer Control in WPF

Saturday, 20 December 2008 02:11 by ugur

XPS is a file format that is started to be commonly used with the release of Windows Vista. Word, Excel, PowerPoint files can be translated into XPS format and can be displayed even in a computer in which Office is not installed via the help of an explorer program such as Internet Explorer 7. In this post, I will try to explain how to display XPS formatted files in WPF (Windows Presentation Foundation) applications with DocumentViewer control. 

We need an XpsDocument object in order to display a XPS file on DocumentView that is a control comes with WPF. Because this class is not included in mscorlib.dll, we must add ReachFramework.dll to our project.

Adding ReachFramework.dll to project's references
Adding ReachFramework.dll to project's references

We can move to our application part after adding related dll file to our project references. In this part the procedure is very simple actually; we add a DocumentViewer control to our application form and we add two code lines that can be seen below to the Loaded event of the application form.

Window1.xaml

<Window x:Class="WpfDocumentViewerXps.Window1"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   Title="DocumentViewer ile XPS Dosyalarının Görüntülemesi" Height="320" Width="600">

    <Grid>

        <DocumentViewer Name="documentViewer1" />

    </Grid>

</Window>


Window1.xaml.cs

...

using System.Windows.Xps.Packaging; //Required namespace

namespace WpfDocumentViewerXps

{

    public partial class Window1 : Window

    {

        public Window1()

        {

            InitializeComponent();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)

        {

            //With GetFixedDocumentSequence method, XpsDocument can get XPS file content

            XpsDocument xps = new XpsDocument(@"D:\test.xps", System.IO.FileAccess.Read);

            documentViewer1.Document = xps.GetFixedDocumentSequence();

        }

    }

}

 

XPS document can be seen on DocumentViewer control
XPS document can be seen on DocumentViewer control

 

Tags:  
Categories:   .NET Framework
Actions:   E-mail | del.icio.us | Permalink | Comments (8) | Comment RSSRSS comment feed

Inserting Item to DataBounded DropDownList

Thursday, 11 December 2008 09:57 by ugur

In the conditions that we load the records to DropDownList control from the database, all of us want the first choice of the DropDownList control a user informative text. I am sure; it is a necessity for every application to display the first item like “Choose a city”, “Choose a category” etc. choices and then list other items coming from the database. Actually, it is not a logic way to add a “Choose a city” record to the Cities table in the database; thus; we must create a different solution way for this issue! If we want to solve this issue in SQL Server side, UNION terms can be used. However, in this post, I want to discuss another different solution way.      

Actually, this process is a very simple and useful solution way. First, we add the informative text to the DropDownList control as a ListItem from the designer part. We add the informative text to the items collection and then we change the AppendDataBoundItems property of the DropDownList as true. At last, the added choice will be listed as a DropDownList control item.

<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"

    DataSourceID="SqlDataSource1" DataTextField="SehirAdi" DataValueField="SehirId">

    <asp:ListItem Value="-1">Bir şehir seçin</asp:ListItem>

</asp:DropDownList>

AppendDataBoundItems

 This is an alternative way for UNION and UNION ALL terms and we should keep this in our minds as a hint…

 
Add to Technorati Favorites