wpf by H0e7Tt

VIEWS: 7 PAGES: 13

									Porting a Win Forms app to WPF
Caleb Vear, dotNET solutions
Overview
• An Introduction to WPF
• How I ported the catalog application
• Issues with the porting process
What do you need to develop WPF
applications?

• The .NET 3 Framework
http://www.microsoft.com/downloads/details.aspx?FamilyID=10cc340b-f857-4a14-83f5-25634c3bf043&DisplayLang=en




• Visual Studio 2005 extensions for .NET 3.0
http://www.microsoft.com/downloads/details.aspx?FamilyID=f54f5537-cc86-4bf5-ae44-f5a1e805680d&DisplayLang=en




• Microsoft Windows SDK for Windows Vista
http://www.microsoft.com/downloads/details.aspx?familyid=7614FE22-8A64-4DFB-AA0C-DB53035F40A0&displaylang=en




• Expression Blend
http://www.microsoft.com/expression/products/overview.aspx?key=blend
What is WPF?
• WPF is a new API for building Windows applications
What is WPF good for?
• To enable designers and developers to work together

• To allow an easy way to customize the look of controls without changing
  its behaviour

• To allow 3D graphics more easily in Windows applications

• To allow an easy way to do animations in Windows applications

• To enable the creation of applications which scale nicely to
  high resolution screens
Overview of WPF Architecture
              • Most of WPF is written in managed
                code

              • milcore is the only unmanaged
                component of WPF
Important WPF Concepts
•   XAML – Extensible Application Mark-up Language
•   Dependency Properties
•   Routed Events
•   Commands
•   Styles
•   Control Templates
Dependency Properties Example
<Window x:Class="WindowsApplication1.Window1"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
          >
<Grid x:Name="myGrid" Margin="20">
          <TextBlock>
                   Sample Text outside the ItemsControl block
          </TextBlock>
          <ItemsControl Foreground="Red" VerticalAlignment="Center">
                   <TextBlock>Sample Text without foreground</TextBlock>
                   <TextBlock Foreground="Blue">Sample Text with
foreground</TextBlock>
          </ItemsControl>
</Grid>
</Window>
Routed Events
How did I port the application?
•   Created a new WPF project
•   Created a test project for testing styles
•   Shared the non Windows Forms class files
•   Separated the main form into two partial class files
    • One file containing platform specific methods
    • The other containing platform independent methods
Platform                       Platform
Independent                    Dependent
• Methods to load local data   • Methods to change the
• Methods to cache data          cursor
• Methods to load data from    • Properties to set the
  the web service                status bar text
                               • Methods to show the
                                 different pages
Issues
• The Frame control doesn’t support scripting objects
• Layout issues with Winforms on WPF
  • Winforms controls will always be rendered over the top of WPF
    controls
  • Winforms controls can’t be scaled or transformed
  • Winforms controls can’t be rotated or skewed
Useful Links
Windows Presentation Foundation SDK Blog
http://blogs.msdn.com/wpfsdk/




WPFPedia.com
http://www.wpfpedia.com




Windows Vista Technical Articles
A Guided Tour of Windows Presentation Foundation
http://msdn2.microsoft.com/en-us/library/aa480221.aspx

								
To top