290 likes | 511 Views
A Lap Around Windows Presentation Foundation. Why hasn’t UX taken off in software?. Win32. Animation. Documents. It’s Difficult!. DirectX. 3D. 2D. MFC. Data Binding. Styled Controls. Windows Forms. Video. HTML. Windows Presentation Foundation provides….
E N D
Why hasn’t UX taken off in software? Win32 Animation Documents It’s Difficult! DirectX 3D 2D MFC Data Binding Styled Controls Windows Forms Video HTML
Windows Presentation Foundation provides… • Unified approach to UI, Documents, and Media • Integration as part of development and experience • Integrated, vector-based composition engine • Utilizing the power of the PC • throughout the graphics stack • Declarative programming • Bringing designers directly into • application development
Windows Presentation Foundation… “Windows Presentation Foundation is the future of Windows presentation technology” • WPF is great for… • Web sites that want to push the limits of user experiences • Windows applications with complex data visualization scenarios • However, other technologies are often still better choices today • Windows Forms is still the best solution for mainstream rich client Windows applications • DirectX is still the platform for extremely intensive graphics (games, CAD applications) • ASP.NETis the reach solution for server-based platform-agnostic applications
What is XAML? eXtensible Application Markup Language Declarative markup language for describing user interfaces
Why Declarative? <Button Background="Red">Hello World!</Button> vs. Button btn = new Button(); btn.Background = Colors.Red; btn.Content = "Hello World!"; this.Children.Add( btn );
Designer Developer Why have XAML?
Types of WPF applications Browser Installed
Layout • Canvas • StackPanel • DockPanel • WrapPanel • Grid
Controls • All standard controls represented • Some new controls • Classes are unique to Windows Presentation Foundation • System.Windows.Controls, not system.Windows.Forms.Controls
Style • Lookless controls • Provide default look-and-feel, can be overridden • Logical Tree vs. Visual Tree • Logical tree is a binary representation of the source XAML • Visual tree is a scene graph which contains all the rendering data needed to compose the page • Override the Visual Tree to style controls
Logical and Visual Trees <StackPanel> <ListBox> <ListBoxItem>Cat</ListBoxItem> <ListBoxItem>Dog</ListBoxItem> </ListBox> <Button>Hello World!</Button> </StackPanel>
Actions • Triggers • Allow some UI events to be handled by XAML, rather than code-behind • Useful for things like “mouse over” effects • Events • Controls support all standard events such as click, key press, selection changed, etc • Events are handled in a code-behind file using either C# or VB
Data Binding Control Property • Target • Any property, any element • Source • CLR Object • WPF Element • ADO.NET • XML • Multiple models • One Time • One Way • Two Way Binding Property “Data Item”
XPS Content • Fixed Documents • High-fidelity fixed layout for precise printing and viewing • WYSIWYG
Content • Flow Documents • Paginated, multi-column rich text
Co-existence with Windows Forms WPF ships with technology allowing for the creation of “hybrid” applications containing both WPF and Windows Forms content.
Goals of “Crossbow” • Preserve existing Windows Forms investments • Leverage existing ActiveX and 3rd party controls • Allow customers to migrate to WPF at their own pace, avoiding total rewrites
“Crossbow” Technology • Services to support co-existence • Unit conversions • Focus and Keyboard management • “Extensible property” management • Two “host” controls • WindowsFormsHost • ElementHost • Simultaneous data source binding • Extend Visual Studio’s designers
Limitations to “Crossbow” • Limited to only one top-level control • However, that control may be a container for many children • Windows Forms controls will always appear atop WPF controls • Limitation to Z-Order logic
Windows Presentation Foundation Resources • Dev Center Guidelines • http://msdn.microsoft.com/windowsvista/experience/ • Windows Presentation Foundation Home • http://msdn.microsoft.com/windowsvista/building/presentation/default.aspx • Microsoft Expression • http://www.microsoft.com/products/expression/en/default.mspx • Interop / Migration • http://msdn.microsoft.com/winfx/reference/presentation/default.aspx