SlideShare une entreprise Scribd logo
1  sur  73
Télécharger pour lire hors ligne
Windows Presentation
Foundation
Max Knor
Developer Evangelist
Microsoft Austria
http://www.knor.net
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
Demo

WPF Puzzle
Why WPF? Another UI Framework?
 New Display Engine
   Based on Direct3D  no window handles
     Leverages Modern Hardware (GPUs)
     Resolution Independence
     Vectorgraphics  Scalable

 Multimedia Integration
   Controls + Documents + Video/Audio

 New .NET based Development Concept
   New class libraries
   Seperated UI vs. Logic
     XAML – XML based UI Specification language
Developer Designer Collaboration




  Designer                     Developer
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
XAML
 Extensible Application Markup Language

 Generic XML Object Instantiation

 Not How – but What!
   Creates Object Hierarchies


 Used in
   Windows Presentation Foundation
   Windows Workflow Foundation
XAML vs. C#

<Button Background=quot;Redquot;>
     Click Me!
</Button>


Button button1 = new Button();
button1.Content = quot;Click Me!quot;;
button1.Background = new SolidColorBrush(
     Colors.Red);
XAML vs. C#
 XML Namespaces <--> .NET Namespaces

 XML Elements <--> .NET Objects

 XML Attributes <--> .NET Object Properties
Demo

XAML
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
WPF Positioning
 Absolute Positioning
   X / Y, Width / Height


 Relative Positioning
   NO X/Y, Width/Height
   Margin
   Alignment

      <Button Margin=quot;20,10,20,10quot;>Hallo Welt</Button>
WPF Positioning - Alignment
  HorizontalAlignment
       Stretch, Left, Right, Center
  VerticalAlignment
       Stretch, Top, Center, Bottom




 <Button HorizontalAlignment=quot;Stretchquot;   <Button HorizontalAlignment=quot;Leftquot;
          VerticalAlignment=quot;Stretchquot;>            VerticalAlignment=quot;Bottomquot;>
      Hallo Welt                              Hallo Welt
 </Button>                               </Button>
Layout Controls
 StackPanel
   Underneath, side-by-side
 WrapPanel
   Same but with automatic wrapping


 Canvas
   X-,Y- Positions


 DockPanel
 Grid
 ...
Demo

Using Layout Controls
Topics

 Overview
 XAML
 Dependency Objects & Routed Events
 Layout Panels
 Controls
 Styles, Templates & Resources
 Commands
 Data Binding
Class Hierarchy
Simple Controls

• PasswordBox

• ScrollBar

• ProgressBar

• Slider

• TextBox

• RichTextBox
Content Controls
                   ScrollBarViewer
 Button
                   ToolTip
 RepeatButton
 ToggleButton
                   UserControl
                   Window
 CheckBox
                   NavigationWindow
 RadioButton

 Label

 Frame

 ListBoxItem
 StatusBarItem
Demo

Content Controls
Headered Content Controls
 Content Control plus header

   Expander

   MenuItem

   GroupBox

   TabItem

   …
Items Controls
 Container for multiple items (lists)

    ListBox
    ComboBox

    Menu
    ContextMenu
    StatusBar

    TreeView
    TabControl

    ...
Demo

Listbox, Toolbar, Menu
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
Dependency Properties
 Values stored in a central dictionary
   Instead of being stored in a private member


 Can include additional metadata (like default value)

 Manipulated by the WPF runtime
   Databinding
   Animation, Styles, etc…
Dependency Properties
public class MyDependencyObject : DependencyObject
{
  public static readonly DependencyProperty
       SomeStateProperty =
       DependencyProperty.Register(quot;SomeStatequot;,
           typeof(String), typeof(MyDependencyObject));

    public string SomeState
    {
      get { return (string)this.GetValue(SomeStateProperty); }
      set { this.SetValue(SomeStateProperty, value); }
    }
}
Attached Properties

 Store Properties of one control on another
 one

<Grid>
 <Button Grid.Column=“0quot; Grid.Row=quot;40quot;>
  Click Me!
 </Button>
</Grid>
Demo

Dependency Properties
Attached Properties
Routed Events
             Preview   Application

             Preview    Window
 Tunneling




                                     Bubbling
             Preview      Grid

             Preview     Button

             Preview    Canvas

             Preview     Ellipse
Routed Events (Attached Events)

 “Collect” events at a higher hierarchy level


<Canvas Button.Click=“Button_Click”>
 <Button>
  Click Me!
 </Button>
</Canvas>
Events
 Create Routed Events

public static readonly RoutedEvent TapEvent =
          EventManager.RegisterRoutedEvent(
          quot;Tapquot;, RoutingStrategy.Bubble, typeof(RoutedEventHandler),
                   typeof(MyButtonSimple));


                 public event RoutedEventHandler Tap {
                    add { AddHandler(TapEvent, value); }
                    remove { RemoveHandler(TapEvent, value); }
                 }



 Use RoutedEventArgs.Source instead of sender
Demo

Routed Events
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
Designer   Developer
Styles are about
setting properties…
Demo

Basic Styles
Resources
Resource Hierarchy
                                        <Window>
   System Resources                      <Window.Resources>
                                          ...
                                         </Window.Resources>
Application   Application
Resources     Resources                  <Grid>
                                          <Grid.Resources>
                                           ...
   Window/Page     Window/Page
                                          </Grid.Resources>
    Resources       Resources
                                          <ListBox>
 Element               Element             <ListBox.Resources>
Resources             Resources            ...
                                           </ListBox.Resources>
                                          </ListBox>
               Element       Element
                                         </Grid>
              Resources     Resources
                                        </Window>
Automatic Styles/Templates
 Most resources must use x:Key
 Optional with Styles and Data Templates
   Can use TargetType or DataType instead
   Applied to target automatically – no reference required




     <Window.Resources>
      <Style TargetType=quot;{x:Type TextBlock}quot;>
       <Setter Property=quot;Marginquot; Value=quot;5quot; />
      </Style>
     </Window.Resources>
Lookless Controls and Templates
 Control implies behaviour

 Probably supplies default look
   Designer free to supply new look
Demo

Control Templates
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
Data Binding
 Concept




 Binding Source
   On<PropertyName>Changed
   INotificationPropertyChanged
   DependencyProperty
Binding in Markup




<Image Source=quot;truck.pngquot;
                                    <Slider Orientation=
Canvas.Left=
                                      quot;Horizontalquot;
  quot;{Binding Path=Value,
                                     Name=quot;horzPosquot;
      ElementName=horzPos}quot;
                                     Value=quot;40quot;/>
/>


 {Binding Path=Value, ElementName=horzPos}
Demo

UI Element Binding
Object Binding
Share Common Source

                           DataContext=
            StackPanel      {Binding
                              Source={StaticResource myData}}



                   HorizontalSlider
                         Value=
                          {Binding Path=XPos,
                                   Path=XPos}
   Image                    Source={StaticResource myData}}
Canvas.Left=
 {Binding Path=XPos,
          Path=XPos}
   Source={StaticResource myData}}
Provide Data From Code
 May be easier to load data in codebehind
 Can set DataContext in code

  Foo myDataObject = new Foo();
  myDataObject.Bar = 42;

  // Set DataContext
  myWindow.DataContext = myDataObject;
Data Binding – Conversion & Validation




 Validation
   ValidationRule


 Converter
   IValueConverter,
   IMultiValueConverter
Demo

Databinding to CLR Objects
Data and Controls

   ContentControl – singular content
      Button, CheckBox, Label, ListBoxItem, …
   ItemsControl – plural content
      ListBox, ComboBox, Menu, TabControl, ToolBar, …
   Can use data objects as content

myButton.Content = new Car();

                           myListBox.Items.Add(new Car());

              Car c = (Car) myListBox.SelectedItem;
Data Templates

class Car
{
  string Image {get;set}
  string Model {get;set}
}
                             DataTemplate


<DataTemplate x:Key=quot;carTemplatequot;>
 <Border BorderBrush=quot;Bluequot; BorderThickness=quot;2quot; Background=quot;LightGrayquot;
      Margin=quot;10quot; Padding=quot;15,15,15,5quot;>
  <StackPanel>
   <Image HorizontalAlignment=quot;Centerquot; Source=quot;{Binding Path=Image}quot; />
   <Border HorizontalAlignment=quot;Centerquot; BorderBrush=quot;Navyquot;
        Background=quot;#DDFquot; BorderThickness=quot;1quot; Margin=quot;10quot; Padding=quot;3quot;>
     <TextBlock FontSize=quot;18quot; Text=quot;{Binding Path=Model}quot; />
   </Border>
  </StackPanel>
 </Border>
</DataTemplate>
Demo

Databinding a list
Datatemplates
Topics

 Overview
 XAML
 Layout Panels
 Controls
 Dependency Objects & Routed Events
 Styles, Templates & Resources
 Data Binding
Have a look at
 XAML Powertoys
    (http://karlshifflett.wordpress.com/xaml-power-toys/)


 WPF Toolkit – Datagrid, DatePicker, Ribbon
    (www.codeplex.com/wpf/)


 WPF Themes
    (www.codeplex.com/wpfthemes/)


 Silverlight Toolkit
    (www.codeplex.com/silverlight/)
Contact




Max Knor
Developer Evangelist
Microsoft Austria


http://www.knor.net
WPF Commands
WPF Commands
 GOF Command Pattern

 Decoupling control and command

 ICommand interface
   Execute(), CanExecute()
   Implemented by RoutedUICommand


 Source implements ICommandSource
Commands Architecture
Defining Commands
 Controls define a command
 <Button Command=quot;ApplicationCommands.Newquot;>
       <Image Source=quot;toolbargraphics/New.bmpquot; />
 </Button>

 CommandBindings define the handler

<Window.CommandBindings>
  <CommandBinding
      Command=quot;ApplicationCommands.Newquot;
      Executed=quot;FileNewquot;
      CanExecute=quot;CanFileNewquot; />
</Window.CommandBindings>
Command Libraries
 Predefined Command Libraries
   ApplicationCommands
   ComponentCommands
   EditingCommands
   MediaCommands
   NavigationCommand
Demo

CommandBindings
Custom Commands

 Instantiate an RoutedUICommand

 Assign InputGestures

 Pack into CommandLibrary
Demo

Custom Command
Interop and Migration
Interoperability!
 Can use WPF with existing code
   WPF inside existing code
   Existing code inside WPF


 Interop at the component level

 Maximum richness => all WPF
Airspace
One pixel, one technology
 File Edit View Help        File Edit View Help



 Win32       WPF            Win32       WPF



 DirectX                    DirectX
Airspace

File Edit View Help   File Edit View Help

                      Win32
Win32
                         WPF
               WPF

                            DirectX
DirectX
Chrome and Canvas


                     Chrome



                    Canvas
Mixed Application Ideas
 A new look for your chrome
 Visual effects for your canvas
 WPF for faster rendering?
 Wizards and help systems
 Generate HTML => Generate XAML
Windows Forms

private void WindowLoaded(object sender, EventArgs e)
{
   WindowsFormsHost host = new WindowsFormsHost();
   host.Height = new Length(120);
   host.Width = new Length(150);
   swf.Control child = new UserControl1();
   child.Dock = swf.DockStyle.None;
   host.AddChild(child);
   border.Child = host;
}
Demo

WPF <--> Windows Forms Interop
Summary
 Can use WPF with existing code

 Maximum richness => all WPF

 Interop is for components
WPF Overview (40

Contenu connexe

Tendances

ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentationThanh Tuong
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootJosué Neis
 
Google Chrome DevTools features overview
Google Chrome DevTools features overviewGoogle Chrome DevTools features overview
Google Chrome DevTools features overviewOleksii Prohonnyi
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!Jakub Kubrynski
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Python Testing 101 with Selenium
Python Testing 101 with SeleniumPython Testing 101 with Selenium
Python Testing 101 with SeleniumLeonardo Jimenez
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Gunith Devasurendra
 
Presentation wpf
Presentation wpfPresentation wpf
Presentation wpfdanishrafiq
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation frameworkdoai tran
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsHansol Lee
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample applicationAntoine Rey
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Edureka!
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSNaga Harish M
 

Tendances (20)

Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Google Chrome DevTools features overview
Google Chrome DevTools features overviewGoogle Chrome DevTools features overview
Google Chrome DevTools features overview
 
Reactjs
Reactjs Reactjs
Reactjs
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Python Testing 101 with Selenium
Python Testing 101 with SeleniumPython Testing 101 with Selenium
Python Testing 101 with Selenium
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
Presentation wpf
Presentation wpfPresentation wpf
Presentation wpf
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation framework
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjects
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 

En vedette

Windows Presentation Foundation
Windows Presentation Foundation  Windows Presentation Foundation
Windows Presentation Foundation Deepika Chaudhary
 
Windows presentation foundation
Windows presentation foundationWindows presentation foundation
Windows presentation foundationNaga Harish M
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 daysUdaya Kumar
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCKhaled Musaied
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial Jm Ramos
 
Integer Review!
Integer Review!Integer Review!
Integer Review!ejboggs
 
08 Testy První Matematické Lekce
08  Testy  První Matematické Lekce08  Testy  První Matematické Lekce
08 Testy První Matematické Lekcejedlickak07
 
Fornitures de rellotges
Fornitures de rellotgesFornitures de rellotges
Fornitures de rellotgesmarblocs
 
Surface Computing
Surface ComputingSurface Computing
Surface Computingrandyp311
 

En vedette (20)

An Introduction to WPF
An Introduction to WPFAn Introduction to WPF
An Introduction to WPF
 
Windows Presentation Foundation
Windows Presentation Foundation  Windows Presentation Foundation
Windows Presentation Foundation
 
Windows presentation foundation
Windows presentation foundationWindows presentation foundation
Windows presentation foundation
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
C#.NET
C#.NETC#.NET
C#.NET
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
WPF - An introduction
WPF - An introductionWPF - An introduction
WPF - An introduction
 
C# basics
 C# basics C# basics
C# basics
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
Integer Review!
Integer Review!Integer Review!
Integer Review!
 
Beethoven
BeethovenBeethoven
Beethoven
 
09 FóRky
09  FóRky09  FóRky
09 FóRky
 
Blending In
Blending InBlending In
Blending In
 
Class Act
Class ActClass Act
Class Act
 
she de franco.......bueno bueno y juan pablo
she de franco.......bueno bueno y juan pabloshe de franco.......bueno bueno y juan pablo
she de franco.......bueno bueno y juan pablo
 
08 Testy První Matematické Lekce
08  Testy  První Matematické Lekce08  Testy  První Matematické Lekce
08 Testy První Matematické Lekce
 
Fornitures de rellotges
Fornitures de rellotgesFornitures de rellotges
Fornitures de rellotges
 
Surface Computing
Surface ComputingSurface Computing
Surface Computing
 

Similaire à WPF Overview (40

Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...goodfriday
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration{item:foo}
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2Jim Driscoll
 
WPF & Silverlight UI
WPF & Silverlight UIWPF & Silverlight UI
WPF & Silverlight UIDave Allen
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and DashboardsAtlassian
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2borkweb
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulationborkweb
 
Create a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchCreate a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchJames Pearce
 
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8netmind
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data BindingDoncho Minkov
 
A mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutesA mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutesJames Pearce
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQueryAlan Hecht
 

Similaire à WPF Overview (40 (20)

Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
java ee 6 Petcatalog
java ee 6 Petcatalogjava ee 6 Petcatalog
java ee 6 Petcatalog
 
WPF & Silverlight UI
WPF & Silverlight UIWPF & Silverlight UI
WPF & Silverlight UI
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
JavaEE Spring Seam
JavaEE Spring SeamJavaEE Spring Seam
JavaEE Spring Seam
 
WPF Fundamentals
WPF FundamentalsWPF Fundamentals
WPF Fundamentals
 
WPF and Databases
WPF and DatabasesWPF and Databases
WPF and Databases
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulation
 
Widget Tutorial
Widget TutorialWidget Tutorial
Widget Tutorial
 
Create a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchCreate a mobile web app with Sencha Touch
Create a mobile web app with Sencha Touch
 
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
netmind - Primer Contacto con el Desarrollo de Aplicaciones para Windows 8
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data Binding
 
A mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutesA mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutes
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Struts2
Struts2Struts2
Struts2
 
Vb.Net Web Forms
Vb.Net  Web FormsVb.Net  Web Forms
Vb.Net Web Forms
 

Plus de Martha Rotter

EdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
EdTech 2012 Keynote: Digital Literacy - Your Message is Your MediumEdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
EdTech 2012 Keynote: Digital Literacy - Your Message is Your MediumMartha Rotter
 
Curing Your Skin With Food
Curing Your Skin With FoodCuring Your Skin With Food
Curing Your Skin With FoodMartha Rotter
 
Designing Narrative Content Workshop
Designing Narrative Content WorkshopDesigning Narrative Content Workshop
Designing Narrative Content WorkshopMartha Rotter
 
Introducing the Windows Phone Application Platform
Introducing the Windows Phone Application PlatformIntroducing the Windows Phone Application Platform
Introducing the Windows Phone Application PlatformMartha Rotter
 
OMG TMI!!!!!!!!111111111111111
OMG TMI!!!!!!!!111111111111111OMG TMI!!!!!!!!111111111111111
OMG TMI!!!!!!!!111111111111111Martha Rotter
 
Building Multi-Touch Experiences
Building Multi-Touch ExperiencesBuilding Multi-Touch Experiences
Building Multi-Touch ExperiencesMartha Rotter
 
Sketch Flow Overview
Sketch Flow OverviewSketch Flow Overview
Sketch Flow OverviewMartha Rotter
 
Creating Video Games From Scratch Sky Con
Creating Video Games From Scratch Sky ConCreating Video Games From Scratch Sky Con
Creating Video Games From Scratch Sky ConMartha Rotter
 
Client Continuum Dec Fy09
Client Continuum Dec Fy09Client Continuum Dec Fy09
Client Continuum Dec Fy09Martha Rotter
 
Silverlight Ux Talk External
Silverlight Ux Talk ExternalSilverlight Ux Talk External
Silverlight Ux Talk ExternalMartha Rotter
 
Podcasting Inside the Evil Empire
Podcasting Inside the Evil EmpirePodcasting Inside the Evil Empire
Podcasting Inside the Evil EmpireMartha Rotter
 
Silverlight For Students
Silverlight For StudentsSilverlight For Students
Silverlight For StudentsMartha Rotter
 
Silverlight2 Deepdive Mix08 External
Silverlight2 Deepdive Mix08 ExternalSilverlight2 Deepdive Mix08 External
Silverlight2 Deepdive Mix08 ExternalMartha Rotter
 
Ruby & Python with Silverlight O RLY? YA RLY!
Ruby & Python with Silverlight O RLY? YA RLY!Ruby & Python with Silverlight O RLY? YA RLY!
Ruby & Python with Silverlight O RLY? YA RLY!Martha Rotter
 

Plus de Martha Rotter (16)

EdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
EdTech 2012 Keynote: Digital Literacy - Your Message is Your MediumEdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
EdTech 2012 Keynote: Digital Literacy - Your Message is Your Medium
 
Beware the Shiny!
Beware the Shiny!Beware the Shiny!
Beware the Shiny!
 
Curing Your Skin With Food
Curing Your Skin With FoodCuring Your Skin With Food
Curing Your Skin With Food
 
Designing Narrative Content Workshop
Designing Narrative Content WorkshopDesigning Narrative Content Workshop
Designing Narrative Content Workshop
 
Introducing the Windows Phone Application Platform
Introducing the Windows Phone Application PlatformIntroducing the Windows Phone Application Platform
Introducing the Windows Phone Application Platform
 
OMG TMI!!!!!!!!111111111111111
OMG TMI!!!!!!!!111111111111111OMG TMI!!!!!!!!111111111111111
OMG TMI!!!!!!!!111111111111111
 
Building Multi-Touch Experiences
Building Multi-Touch ExperiencesBuilding Multi-Touch Experiences
Building Multi-Touch Experiences
 
Sketch Flow Overview
Sketch Flow OverviewSketch Flow Overview
Sketch Flow Overview
 
Creating Video Games From Scratch Sky Con
Creating Video Games From Scratch Sky ConCreating Video Games From Scratch Sky Con
Creating Video Games From Scratch Sky Con
 
Composite WPF
Composite WPFComposite WPF
Composite WPF
 
Client Continuum Dec Fy09
Client Continuum Dec Fy09Client Continuum Dec Fy09
Client Continuum Dec Fy09
 
Silverlight Ux Talk External
Silverlight Ux Talk ExternalSilverlight Ux Talk External
Silverlight Ux Talk External
 
Podcasting Inside the Evil Empire
Podcasting Inside the Evil EmpirePodcasting Inside the Evil Empire
Podcasting Inside the Evil Empire
 
Silverlight For Students
Silverlight For StudentsSilverlight For Students
Silverlight For Students
 
Silverlight2 Deepdive Mix08 External
Silverlight2 Deepdive Mix08 ExternalSilverlight2 Deepdive Mix08 External
Silverlight2 Deepdive Mix08 External
 
Ruby & Python with Silverlight O RLY? YA RLY!
Ruby & Python with Silverlight O RLY? YA RLY!Ruby & Python with Silverlight O RLY? YA RLY!
Ruby & Python with Silverlight O RLY? YA RLY!
 

Dernier

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 

Dernier (20)

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 

WPF Overview (40

  • 1. Windows Presentation Foundation Max Knor Developer Evangelist Microsoft Austria http://www.knor.net
  • 2. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 4. Why WPF? Another UI Framework? New Display Engine Based on Direct3D  no window handles Leverages Modern Hardware (GPUs) Resolution Independence Vectorgraphics  Scalable Multimedia Integration Controls + Documents + Video/Audio New .NET based Development Concept New class libraries Seperated UI vs. Logic XAML – XML based UI Specification language
  • 5. Developer Designer Collaboration Designer Developer
  • 6. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 7. XAML Extensible Application Markup Language Generic XML Object Instantiation Not How – but What! Creates Object Hierarchies Used in Windows Presentation Foundation Windows Workflow Foundation
  • 8. XAML vs. C# <Button Background=quot;Redquot;> Click Me! </Button> Button button1 = new Button(); button1.Content = quot;Click Me!quot;; button1.Background = new SolidColorBrush( Colors.Red);
  • 9. XAML vs. C# XML Namespaces <--> .NET Namespaces XML Elements <--> .NET Objects XML Attributes <--> .NET Object Properties
  • 11. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 12. WPF Positioning Absolute Positioning X / Y, Width / Height Relative Positioning NO X/Y, Width/Height Margin Alignment <Button Margin=quot;20,10,20,10quot;>Hallo Welt</Button>
  • 13. WPF Positioning - Alignment HorizontalAlignment Stretch, Left, Right, Center VerticalAlignment Stretch, Top, Center, Bottom <Button HorizontalAlignment=quot;Stretchquot; <Button HorizontalAlignment=quot;Leftquot; VerticalAlignment=quot;Stretchquot;> VerticalAlignment=quot;Bottomquot;> Hallo Welt Hallo Welt </Button> </Button>
  • 14. Layout Controls StackPanel Underneath, side-by-side WrapPanel Same but with automatic wrapping Canvas X-,Y- Positions DockPanel Grid ...
  • 16. Topics Overview XAML Dependency Objects & Routed Events Layout Panels Controls Styles, Templates & Resources Commands Data Binding
  • 18. Simple Controls • PasswordBox • ScrollBar • ProgressBar • Slider • TextBox • RichTextBox
  • 19. Content Controls ScrollBarViewer Button ToolTip RepeatButton ToggleButton UserControl Window CheckBox NavigationWindow RadioButton Label Frame ListBoxItem StatusBarItem
  • 21. Headered Content Controls Content Control plus header Expander MenuItem GroupBox TabItem …
  • 22. Items Controls Container for multiple items (lists) ListBox ComboBox Menu ContextMenu StatusBar TreeView TabControl ...
  • 24. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 25. Dependency Properties Values stored in a central dictionary Instead of being stored in a private member Can include additional metadata (like default value) Manipulated by the WPF runtime Databinding Animation, Styles, etc…
  • 26. Dependency Properties public class MyDependencyObject : DependencyObject { public static readonly DependencyProperty SomeStateProperty = DependencyProperty.Register(quot;SomeStatequot;, typeof(String), typeof(MyDependencyObject)); public string SomeState { get { return (string)this.GetValue(SomeStateProperty); } set { this.SetValue(SomeStateProperty, value); } } }
  • 27. Attached Properties Store Properties of one control on another one <Grid> <Button Grid.Column=“0quot; Grid.Row=quot;40quot;> Click Me! </Button> </Grid>
  • 29. Routed Events Preview Application Preview Window Tunneling Bubbling Preview Grid Preview Button Preview Canvas Preview Ellipse
  • 30. Routed Events (Attached Events) “Collect” events at a higher hierarchy level <Canvas Button.Click=“Button_Click”> <Button> Click Me! </Button> </Canvas>
  • 31. Events Create Routed Events public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent( quot;Tapquot;, RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple)); public event RoutedEventHandler Tap { add { AddHandler(TapEvent, value); } remove { RemoveHandler(TapEvent, value); } } Use RoutedEventArgs.Source instead of sender
  • 33. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 34. Designer Developer
  • 35. Styles are about setting properties…
  • 37. Resource Hierarchy <Window> System Resources <Window.Resources> ... </Window.Resources> Application Application Resources Resources <Grid> <Grid.Resources> ... Window/Page Window/Page </Grid.Resources> Resources Resources <ListBox> Element Element <ListBox.Resources> Resources Resources ... </ListBox.Resources> </ListBox> Element Element </Grid> Resources Resources </Window>
  • 38. Automatic Styles/Templates Most resources must use x:Key Optional with Styles and Data Templates Can use TargetType or DataType instead Applied to target automatically – no reference required <Window.Resources> <Style TargetType=quot;{x:Type TextBlock}quot;> <Setter Property=quot;Marginquot; Value=quot;5quot; /> </Style> </Window.Resources>
  • 39. Lookless Controls and Templates Control implies behaviour Probably supplies default look Designer free to supply new look
  • 41. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 42. Data Binding Concept Binding Source On<PropertyName>Changed INotificationPropertyChanged DependencyProperty
  • 43. Binding in Markup <Image Source=quot;truck.pngquot; <Slider Orientation= Canvas.Left= quot;Horizontalquot; quot;{Binding Path=Value, Name=quot;horzPosquot; ElementName=horzPos}quot; Value=quot;40quot;/> /> {Binding Path=Value, ElementName=horzPos}
  • 45. Share Common Source DataContext= StackPanel {Binding Source={StaticResource myData}} HorizontalSlider Value= {Binding Path=XPos, Path=XPos} Image Source={StaticResource myData}} Canvas.Left= {Binding Path=XPos, Path=XPos} Source={StaticResource myData}}
  • 46. Provide Data From Code May be easier to load data in codebehind Can set DataContext in code Foo myDataObject = new Foo(); myDataObject.Bar = 42; // Set DataContext myWindow.DataContext = myDataObject;
  • 47. Data Binding – Conversion & Validation Validation ValidationRule Converter IValueConverter, IMultiValueConverter
  • 49. Data and Controls ContentControl – singular content Button, CheckBox, Label, ListBoxItem, … ItemsControl – plural content ListBox, ComboBox, Menu, TabControl, ToolBar, … Can use data objects as content myButton.Content = new Car(); myListBox.Items.Add(new Car()); Car c = (Car) myListBox.SelectedItem;
  • 50. Data Templates class Car { string Image {get;set} string Model {get;set} } DataTemplate <DataTemplate x:Key=quot;carTemplatequot;> <Border BorderBrush=quot;Bluequot; BorderThickness=quot;2quot; Background=quot;LightGrayquot; Margin=quot;10quot; Padding=quot;15,15,15,5quot;> <StackPanel> <Image HorizontalAlignment=quot;Centerquot; Source=quot;{Binding Path=Image}quot; /> <Border HorizontalAlignment=quot;Centerquot; BorderBrush=quot;Navyquot; Background=quot;#DDFquot; BorderThickness=quot;1quot; Margin=quot;10quot; Padding=quot;3quot;> <TextBlock FontSize=quot;18quot; Text=quot;{Binding Path=Model}quot; /> </Border> </StackPanel> </Border> </DataTemplate>
  • 52. Topics Overview XAML Layout Panels Controls Dependency Objects & Routed Events Styles, Templates & Resources Data Binding
  • 53. Have a look at XAML Powertoys (http://karlshifflett.wordpress.com/xaml-power-toys/) WPF Toolkit – Datagrid, DatePicker, Ribbon (www.codeplex.com/wpf/) WPF Themes (www.codeplex.com/wpfthemes/) Silverlight Toolkit (www.codeplex.com/silverlight/)
  • 54. Contact Max Knor Developer Evangelist Microsoft Austria http://www.knor.net
  • 55.
  • 57. WPF Commands GOF Command Pattern Decoupling control and command ICommand interface Execute(), CanExecute() Implemented by RoutedUICommand Source implements ICommandSource
  • 59. Defining Commands Controls define a command <Button Command=quot;ApplicationCommands.Newquot;> <Image Source=quot;toolbargraphics/New.bmpquot; /> </Button> CommandBindings define the handler <Window.CommandBindings> <CommandBinding Command=quot;ApplicationCommands.Newquot; Executed=quot;FileNewquot; CanExecute=quot;CanFileNewquot; /> </Window.CommandBindings>
  • 60. Command Libraries Predefined Command Libraries ApplicationCommands ComponentCommands EditingCommands MediaCommands NavigationCommand
  • 62. Custom Commands Instantiate an RoutedUICommand Assign InputGestures Pack into CommandLibrary
  • 65. Interoperability! Can use WPF with existing code WPF inside existing code Existing code inside WPF Interop at the component level Maximum richness => all WPF
  • 66. Airspace One pixel, one technology File Edit View Help File Edit View Help Win32 WPF Win32 WPF DirectX DirectX
  • 67. Airspace File Edit View Help File Edit View Help Win32 Win32 WPF WPF DirectX DirectX
  • 68. Chrome and Canvas Chrome Canvas
  • 69. Mixed Application Ideas A new look for your chrome Visual effects for your canvas WPF for faster rendering? Wizards and help systems Generate HTML => Generate XAML
  • 70. Windows Forms private void WindowLoaded(object sender, EventArgs e) { WindowsFormsHost host = new WindowsFormsHost(); host.Height = new Length(120); host.Width = new Length(150); swf.Control child = new UserControl1(); child.Dock = swf.DockStyle.None; host.AddChild(child); border.Child = host; }
  • 71. Demo WPF <--> Windows Forms Interop
  • 72. Summary Can use WPF with existing code Maximum richness => all WPF Interop is for components