Download presentation
Presentation is loading. Please wait.
Published byMarlene Cole Modified over 9 years ago
1
WinFX – A Lap Around the Windows Presentation Foundation Bart J.F. De Smet MVP Visual C# info@bartdesmet.net http://blogs.bartdesmet.net/bart
2
Agenda WPF – What’s in a name? Introducing XAML Taming the tools Getting started Controls Layout Databinding Graphics Text and Documents Conclusion + Q&A
3
WPF – What’s in a name? Roadblocks
4
WPF – What’s in a name? Technology Islands
5
WPF – What’s in a name? No Design Protocol
6
WPF – What’s in a name? Your “Dear” Powerful GPU
7
WPF – What’s in a name? True Smart Client Not Possible Everyone has part of the picture, but no one has it together seamless deploy rich user experience navigation connectivity & offline
8
WPF – What’s in a name? Windows Presentation Foundation Vision 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 Ease of deployment Allowing administrators to deploy and manage applications securely
10
Agenda WPF – What’s in a name? Introducing XAML Taming the tools Getting started Controls Layout Databinding Graphics Text and Documents Conclusion
11
Introducing XAML The Art of Declarative Programming History goes on Visual Basic Forms Designer (remember.frm &.frx?) The “Windows Form Designer generated code” Partial classes.NET declarative programming model “eXtensible Application Markup Language” Namespace, Classes, Properties and Events mapping XAML is not WPF only WPF in XAML Integrated UI, Media, Documents in markup Enables developer designer workflow
12
Introducing XAML What’s the big deal? form1.cs public class Form1 : Form : Form{ public Form1() public Form1() { Button b = new Button(); Button b = new Button(); b.Text = "Hello World"; b.Text = "Hello World"; }} dialog1.rc BEGIN DIALOG BUTTON "HELLO WORLD" BUTTON "HELLO WORLD" END DIALOG page1.html <html> Hello World Hello World </html> image1.svg <rect> hello world hello world </rect> window1.xaml <Window xmlns= " http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x= " http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Window1" > Hello World Hello World </Window>
13
Agenda WPF – What’s in a name? Introducing XAML Taming the tools Getting started Controls Layout Databinding Graphics Text and Documents Conclusion + Q&A
14
Taming the tools Developer and Designer Productivity Notepad Once in a WPF developer’s lifetime xp XamlPad The fastest WYSIWYG tool for WPF Visual Studio 2005 “Cider” Your number one development tool Expression Interactive Designer “Sparkle” Closing the gap with the graphical designer
15
XamlPad Visual Studio 2005
16
Agenda WPF – What’s in a name? Introducing XAML Taming the tools Getting started Controls Layout Databinding Graphics Text and Documents Conclusion + Q&A
17
Getting Started The picture that tells it all Applications ActionsContentDataLayout Controls Styling and Templates
18
Controls Talking about challenges Controls are not flexible Low flexibility to adapt controls to the developer’s and end-user’s visual needs. The “gray box” problem Your only customization points are the ones in the property browser. No “pay for play” Advanced customization requires significantly more work (a.k.a. the “OwnerDraw” nightmare).
19
Controls WPF’s “realizing your potential” New controls built for the platform, using the platform Globalization, localization, accessibility, eventing, etc Controls that can contain anything.Content explained Controls that have the look you want Layout, graphics, visuals theming, etc
20
Controls.Content == new(.Text) Replacing.Text but richer WPF C# Button.Content = “Hello World”; WPF XAML Hello World An improved approach for data myButton.Content = new Customer(...); You get back what you put in Developer deals with data, designer deals with the visualization
21
Layout WPF’s Layout Toolbox Canvas The old (bad) absolute positioning StackPanel The simplest automatic layout DockPanel Dock controls on top, left, right, bottom and fill Grid Partitions the UI in rows and columns TextFlow Present text in a (typographically) user-friendly way
22
Controls Layout Styles
23
Databinding Binding in Markup <Image Source="truck.png" Canvas.Left= "{Binding Path=Value, ElementName=horzPos}" /> <Slider Orientation="Horizontal" Name="horzPos" Value="40" /> {Binding Path=Value, ElementName=horzPos}
24
Databinding Object Data Sources Connect UI to data objects E.g. business entities Add to resource dictionary Named source objects element Use with resource binding Source “property” {StaticResource myData} <ObjectDataProvider x:Key="myData" TypeName="Foo" /> … <TextBlock TextContent=" " /> <TextBlock TextContent="{Binding Path=, Source= }" /> <TextBlock TextContent="{Binding Path=, Source={StaticResource myData} }" /> <TextBlock TextContent="{Binding Path=Bar, Source={StaticResource myData} }" />
25
Databinding Binding to XML XML is everywhere Built-in support for XPath <TextBlock TextContent="{Binding XPath=@Make, Source={StaticResource cars} }" /> truck.png … cars.xml …
26
Binding controls Binding objects Binding XML
27
Databinding Controls Think Data ContentControl – singular content Button, CheckBox, Label, ListBoxItem, … ItemsControl – plural content ListBox, ComboBox, Menu, TabControl, ToolBar, … Can use data objects as content myListBox.Items.Add(new Car(…)); myButton.Content = new Car(…); Car c = (Car) myListBox.SelectedItem;
28
Databinding Defining Data Templates DataTemplate class Car { string Image {get;set;} string Model {get;set;} } <Border BorderBrush="Blue" BorderThickness="2" Background="LightGray" Margin="10" Padding="15,15,15,5"> <Border HorizontalAlignment="Center" BorderBrush="Navy" Background="#DDF“ BorderThickness="1" Margin="10" Padding="3">
29
Databinding Using Data Templates Bind to a type … Bind explicitly …
30
Binding with templates
31
Graphics A Macroscopic View WPF is a graphical foundation 2D and 3D graphics Multimedia support A bunch of shapes Transforms Gradients Brushes... Based on vector graphics Superb quality Superb performance
32
Transformations Playing with graphics
33
Text and Documents Text Is Everywhere Natural Reading ClearType Sub-pixel positioning Anti-aliasing Adobe Compact Font Format (CFF) support Controls SinglePageViewer FlowDocument Annotation support
34
Putting it together
35
Agenda WPF – What’s in a name? Introducing XAML Taming the tools Getting started Controls Layout Databinding Graphics Text and Documents Conclusion + Q&A
36
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.