1 / 23

Windows Presentation Foundation

Windows Presentation Foundation. The next generation of Windows Forms. Adam Calderon Principal Engineer Interknowlogy LLC adamc@interknowlogy.com http://blogs.interknowlogy.com/adamcalderon. What is WPF.

leane
Télécharger la présentation

Windows Presentation Foundation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Presentation Foundation The next generation of Windows Forms Adam Calderon Principal Engineer Interknowlogy LLC adamc@interknowlogy.com http://blogs.interknowlogy.com/adamcalderon

  2. What is WPF Windows Presentation Foundation is Microsoft's unified presentation subsystem for Windows, and is exposed through WinFX and XAML. It consists of a display engine and a managed-code framework. Windows Presentation Foundation unifies how Windows creates, displays, and manipulates documents, media, and user interface (UI), enabling developers and designers to create visually stunning, differentiated user experiences

  3. What is WinFx WinFX is Windows Vista's managed-code programming model, building on and extending the .NET Framework. WinFX offers both practical solutions to today's software challenges and new opportunities to create software and services not possible now. It enables both developers and designers to quickly create new applications and experiences that are more reliable and secure, visually stunning, smarter about information management, better connected, and more collaborative.

  4. What is XAML XAML is a markup language that declaratively represents user interfaces for Windows applications, improving the richness of the tools with which developers and designers can compose and repurpose UI. For Web developers, XAML provides a familiar UI description paradigm. XAML also enables the separation of UI design from the underlying code, enabling developers and designers to work more closely together.

  5. Sample XAML <Window x:Class="WindowsApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005" Title="WindowsApplication1"> <Grid> <Label VerticalAlignment="Top" HorizontalAlignment="Left“ Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1“ Margin="32,37,0,0" Width="115.63" Height="23" Name="label1">Hello World</Label> </Grid> </Window>

  6. WPF Application Types • Windows Application • Standard single window type • Browser navigation type • Browser Application • Runs in a sandbox with “Internet Permissions”

  7. Layout Basics • Panels layout children • Size to content • Alignments • Margins • Padding • Content Overflow

  8. Panels – How you layout forms • DockPanel • Allocates the entire edge of the panel area to each child • StackPanel • Lays out children in a vertical or horizontal stack • Grid • Arranges children within a grid • Canvas • Performs no layout logic. Puts children where you tell it to.

  9. Controls • Events • Commands • Built-In Controls

  10. Control Events (Routed Events) • Bubbling • Starts at the current element and bubbles up to the current element’s parent and that elements parent and so on [MouseLeftButtonDown] • Tunneling • Works opposite of bubbling and starts at the root element and works down to the originating element [PreviewMouseLeftButtonDown] • Direct • Works like standard .NET event handling with only direct handlers being notified of events [Click]

  11. Working with Events Halting Events Private void Grid_ButtonDown(object sender, RoutedEventArgs e) { //do something here e.Handled = true; } Determining the Target Private void Grid_ButtonDown(object sender, RoutedEventArgs e) { // who is the originator MessageBox.Show(((System.Windows.Controls.Control)e.OriginalSource).Name); }

  12. Commands • Logical action that can be invoke in several ways • Based on the RoutedCommand Class • Uses both event tunneling [PreviewExecuteEvent] and event bubbling [ExecuteEvent]

  13. Standard Command Classes

  14. Built-In Controls • Not wrappers around old Win32 controls • Native WPF controls • Support styling, resolution independence, data binding, composition and full support for WPF graphic capabilities • Includes Most Standard Controls • Buttons • Slider and Scroll • Text Controls (Textbox, Label) • Menus and Toolbars

  15. Data Binding • Simple Field level Data Binding • Complex Data Binding to multiple controls at a time (Master/Detail/Detail) • Client-Side Sorting and Filtering • Support for binding to Objects, XML and Relational data sources

  16. Simple Data Binding • Simple Data Binding using Business Objects • Support for two-way synchronization in simple objects via the INotifyPropertyChanged interface • Implicit and Declarative binding via the DataContext

  17. Complex Data Binding • Binding to Lists • Supports two-way data binding to list if list inherits from ObservableCollection<T> • Data Templates • Sorting • Filtering • Master/Detail/Detail

  18. Multiple Data Sources • Object Data Source • XML Data Source • Relational Data Source

  19. Styles • Used for both Elements (Controls) and Data Templates • Can be used to set properties (Font) or define the way an object looks • Different types: Inline, Named • Can target a specific type and can inherited like CSS.

  20. Laying out files with Styles in Mind Window1.xaml.cs Contains: Application logic Created by: Application developer Window1.xaml Contains: Principal UI (controls, layout, etc.) Created by: Application developer or designer Design Experience: By hand or using a visual tool Styles.xaml Contains: Application “style” (visual description of UI elements) Created by: Application designer Design Experience: By hand or using a visual tool Data model, event names, element names, etc. Resource names and element types.

  21. Triggers • Property Triggers • Data Triggers • Event Triggers

  22. What else is in WPF • Control Templates • Resources • Graphics • Annimation • Custom Controls • Integration with VS2005 Controls • ClickOnce Deployment

  23. Resources Windows Vista Developers Center http://msdn.microsoft.com/windowsvista/default.aspx Windows Presentation Foundation Forum http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=119&SiteID=1 WinFx December CTP http://msdn.microsoft.com/windowsvista/getthebeta/default.aspx Programming Windows Presentation Foundation (by Chris Sells and Ian Griffiths) http://www.amazon.com/gp/product/0596101139/qid=1136144280/sr=8-1/ref=pd_bbs_1/102-9584211-5272153?n=507846&s=books&v=glance

More Related