Professional Documents
Culture Documents
6460a 01
6460a 01
Windows Presentation
®
Foundation
Module 1: Creating an Application by Using
Windows Presentation Foundation
• Overview of WPF
• WPF Architecture
• Documents
• Application UI
Windows Windows
Presentation Workflow
Foundation Foundation
(WPF) (WF)
Windows
Communication Windows
Foundation CardSpace
(WCF) (WCS)
PresentationFramework
Managed Code
PresentationCore
Common Language
Runtime
User32 DirectX
Kernel
Defining User Interfaces in WPF
</Window>
WPF Capabilities and Features
• Adding Controls
<Application.Resources>
…
</Application.Resources>
</Application>
Defining Windows or Pages
A stand-alone application contains windows or pages
<Grid> <Grid>
… …
</Grid> </Grid>
</Window> </Page>
Adding Controls
Windows and pages contain controls
• The controls are represented by XAML elements
•<Button> and <TextBox> are examples of these
...
<Grid>
<TextBox Name="TextBox1" />
<Button Name="Button1">Click here</Button>
</Grid>
...
Building and Running a WPF Application
You can build and run a WPF application in Visual Studio
Stand-alone or browser application
Event tunneling:
Event routed down element tree
Root element
Event bubbling:
Event routed up element tree Tunnel
Bubble
Child element Child element
#1 #2
Bubble
Tunnel
Leaf element Leaf
#1 element #2
Item clicked
Defining Routed Events
Example of event bubbling
• Define leaf elements inside a container element
• Handle leaf events at the container level
<StackPanel Button.Click="CommonClickHandler">
<Button Name="YesButton">Yes</Button>
<Button Name="NoButton">No</Button>
</StackPanel>
Navigate to a fragment in a
page
NavigationProgress
Navigated
LoadCompleted
FragmentNavigation
NavigationStopped
NavigationFailed
Maintaining State by Using Navigation Services
Next
Page1.xaml Page2.xaml
Back
• FrameworkPropertyMetadata.Journal
• IProvideCustomContentState
Lab: Creating a WPF Application
• Exercise 1: Creating a Stand-Alone WPF Application
Logon information
Virtual machine 6460A-LON-DEV-01
User name Student
Password Pa$$w0rd
• Best Practices
• Tools