Click here to Skip to main content
12,831,317 members (52,390 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 16 Mar 2007

Step into the new Microsoft Windows Presentation Foundation (WPF)

, 16 Mar 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Simple steps to start with the Windows Presentation Foundation


The Microsoft Windows Presentation Foundation (WPF) formerly code named "Avalon" provides the foundation for building applications and high reliability experiences in Longhorn, blending together application UI, documents, and media content, while exploiting the full power of your computer. WPF is the graphical subsystem of .NET frameworks 3.0 formerly called WinFX. XAML is the markup language used to write WPF applications. WPF provides developers and designers with a unified programming model for building rich Windows smart client user experiences that incorporate UI, media, and documents. WPF provides a reliable programming model for building applications and provides a clear separation between the User Interface and the business logic.


Extensible Application Markup Language (XAML) by Microsoft is a declarative XML-based language used to define objects and their properties, relationships and interactions. The acronym originally stood for Extensible Avalon Markup Language, where Avalon was the code name for Windows Presentation Foundation (WPF), but now it stands for Extensible Application Markup Language. XAML files are XML files that generally have the .xaml extension.

XAML is used as a UI objects, events and many others in Windows Presentation Foundation. In Windows Workflow Foundation the Workflow is also defined using XAML. In addition, Visual Studio, SharePoint Designer, Microsoft Expression and XAMLpad are used for XAML file manipulation.

WPF Applications

Windows Presentation Foundation has many good features that enriches your next generation applications. WPF is intended to be the next-generation graphics API for Windows applications on the desktop. Applications written in WPF are visually of a higher quality. The features that enriched in WPF are Graphical Services, Deployment, Interoperability, Media Services, Data Binding, User Interface, Annotations, Imaging, Effects, Text, Input and Accessibility.

Start with a sample WPF web application

After setting your infrastructure for your WPF application development, first open you're your Visual Studio 2005 and create new project. This WPF project template will come under the .NET frameworks 3.0 and select the WinFX Web Browser Application project template. And your new project will be created with two .xaml files and other files associated with the project created.

Add a root Page element to Default.xaml, with custom configurations as per your needs. First the title bar of the browser is set to "My First WPF Application", and then width of the browser is 800 device-independent pixels, then height of the browser is 600 device-independent pixels, then title of the page is "My First WPF Application – Home Page".

If you find the following namespace under your Default.xaml file,

Then replace them with the following namespace.< br/> xmlns=""

Now add a new WinFX page and name it as DisplayPage.xaml. This DisplayPage.xaml file will finally be used to bind display data to the UI.

In the Default.xaml file add the following XAML tags to display a text with hyper linked. The hyperlink will navigate to your next XAML file.

<!--  Add Links to Other Pages Here -->
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" 
    Margin="0 0 0 40">
        <Hyperlink NavigateUri="DisplayPage.xaml">
            Data DisplayPage

In the above format the text will display in your browser. Then you can place the text anywhere in your browser by display formatting. The following XAML tag will help you to format the display of your text.

<!--  Basic Display Formatting Below Text-->
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="Auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="FontFamily" Value="Lucida Console" />
        <Setter Property="FontSize" Value="30" />

Now add an image file to your solution and how it can be displayed. In this sample I'm trying to add an image called tiger.PNG. In the Solution Explorer tree, right-click the image and select Properties from the context menu.

Change the build action from Resource to Content.

And change the copy to output directory as copy always.

And place the following XAML tags in your DisplayPage.xaml file.

<Viewbox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" 
    <Canvas Width="600" Height="600">
            <!-- bounding image Path -->
            <Image Source="tiger.PNG" />

These are the simple steps to start with the Windows Presentation Foundation. Hopefully this will help beginner of WPF.

Setup infrastructure for your application

"WPF/E" (codename) Community Technology Preview for Windows (Feb 2007)
"WPF/E" (codename) Community Technology Preview Sample Pack (Feb 2007)
WPF/E" (codename) Software Development Kit (SDK) Community Technology Preview (Feb 2007)


Microsoft Expression Web Free Trial
Microsoft® Expression Web Quickstart Guide

References< br/>


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chief Technology Officer at Zealots
Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 16 Mar 2007
Article Copyright 2007 by vivekthangaswamy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid