Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Presentation Foundation Adam Calderon Principal Engineer Interknowlogy LLC

Similar presentations


Presentation on theme: "Windows Presentation Foundation Adam Calderon Principal Engineer Interknowlogy LLC"— Presentation transcript:

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

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"> <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

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 AlignmentsMarginsPadding 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 EventsCommands 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 Class Command Types ApplicationCommands Commands common to almost all applications. Includes clipboard commands, undo and redo and document level operations (open,close,print,etc..) ComponentCommands Operations for moving through information such as scroll up and down, move to end, and text selection EditCommands Text editing commands such a bold, italic and alignment MediaCommands Media-playing operations such as transport (play,pause,etc..), volume control and track selection

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 Supports two-way data binding to list if list inherits from ObservableCollection Data Templates SortingFilteringMaster/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 Window1.xaml.csContains: Application logic Created by: Application developer Window1.xamlContains: Principal UI (controls, layout, etc.) Created by: Application developer or designer Design Experience: By hand or using a visual tool Styles.xamlContains: Application “style” (visual description of UI elements) Created by: Application designer Design Experience: By hand or using a visual tool Laying out files with Styles in Mind 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 ResourcesGraphicsAnnimation Custom Controls Integration with VS2005 Controls ClickOnce Deployment

23 Resources Programming Windows Presentation Foundation ( by Chris Sells and Ian Griffiths) http://www.amazon.com/gp/product/0596101139/qid=11361 44280/sr=8-1/ref=pd_bbs_1/102-9584211- 5272153?n=507846&s=books&v=glance WinFx December CTP http://msdn.microsoft.com/windowsvista/getthebeta/default.aspx 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


Download ppt "Windows Presentation Foundation Adam Calderon Principal Engineer Interknowlogy LLC"

Similar presentations


Ads by Google