Your SlideShare is downloading. ×
0
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Windows Presentation Foundation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Windows Presentation Foundation

2,897

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,897
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Windows Presentation Foundation<br />Dawid Cieszyńskicieszak@cieszak.eu<br />
  • 2. Agenda<br />Co to jest? Do czego służy?<br />Porównanie z Windows Forms<br />Język XAML i przykłady kodu<br />Data Binding i Update Trigger<br />Expression Blend<br />Nowe kontrolki w WPF?<br />Podsumowanie<br />
  • 3. Co to jest?<br />Windows Presentation Foundation<br />(System.Windows.*)<br />Windows CardSpace<br />Windows Communication<br />Foundation<br />(System.ServiceModel.*)<br />Windows Workflow Foundation<br />(System.Workflow.*)<br />
  • 4. Do czego służy?<br />
  • 5. Co to jest?<br />Nowa estetyka Windows Vista<br />Transformacje, animacje, przezroczystość, cieniowanie, efekty trójwymiarowe, itp.<br />Style<br />Wyzwalacze<br />
  • 6. WPF vs Windows Forms<br />
  • 7. XAML<br />C#<br />VB.NET<br />&lt;Button Width=&quot;100&quot;&gt; OK<br /> &lt;Button.Background&gt;<br />LightBlue<br /> &lt;/Button.Background&gt;<br />&lt;/Button&gt;<br />Button b1 = new Button();<br />b1.Content = &quot;OK&quot;;<br />b1.Background = new SolidColorBrush(Colors.LightBlue);<br />b1.Width = 100;<br />Dim b1 As New Button<br />b1.Content = &quot;OK&quot;<br />b1.Background = New _SolidColorBrush(Colors.LightBlue)<br />b1.Width = 100<br />XAML = ExtensibleApplicationMarkupLanguage<br />HTML?<br />
  • 8. Przykłady kodu XAML<br />
  • 9. App.xaml<br />&lt;Application x:Class=&quot;WpfApplication1.App&quot;<br />xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br />xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;<br />StartupUri=&quot;MainWindow.xaml&quot;&gt;<br />&lt;Application.Resources&gt;<br /> &lt;/Application.Resources&gt;<br />&lt;/Application&gt;<br />
  • 10. MainWindow.xaml<br />&lt;Window x:Class=&quot;WpfApplication1.Window1&quot;<br />xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br />xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;<br />Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;<br />&lt;Grid&gt;<br />&lt;/Grid&gt;<br />&lt;/Window&gt;<br />
  • 11. Layout<br />DockPanel<br />StackPanel<br />Grid<br />Canvas<br />
  • 12. Przykład XAML<br />&lt;Rectangle Fill=&quot;Red„Width=&quot;150„Height=&quot;100&quot; /&gt;<br />
  • 13. Przykład XAML<br />&lt;Grid ShowGridLines=&quot;True&quot;&gt;<br />&lt;Grid.ColumnDefinitions&gt;<br />&lt;ColumnDefinition /&gt;<br />&lt;ColumnDefinition /&gt;<br />&lt;/Grid.ColumnDefinitions&gt;<br />&lt;Grid.RowDefinitions&gt;<br />&lt;RowDefinition/&gt;<br />&lt;RowDefinition /&gt;<br />&lt;/Grid.RowDefinitions&gt;<br />&lt;Rectangle Fill=&quot;Red&quot; Width=&quot;150&quot; Height=&quot;100„Grid.Column=&quot;1&quot;Grid.Row=&quot;1&quot;/&gt;<br />&lt;/Grid&gt;<br />
  • 14. Przykład XAML<br />&lt;Button Height=&quot;25&quot; Width=&quot;100&quot;Grid.Column=&quot;0„Grid.Row=&quot;0&quot; Click=&quot;Button_Click&quot;/&gt;<br />&lt;Rectangle x:Name=&quot;rect&quot; Fill=&quot;Red&quot;Width=&quot;150&quot; Height=&quot;100&quot;Grid.Column=&quot;1&quot;Grid.Row=&quot;1&quot;/&gt;<br />privatevoidButton_Click(object sender, RoutedEventArgs e)<br />{<br />rect.Fill= newSolidColorBrush(Colors.Blue);<br />}<br />
  • 15. Przykład XAML<br />&lt;Rectangle x:Name=&quot;rect&quot; Width=&quot;150&quot; Height=&quot;100&quot;Grid.Column=&quot;1&quot;Grid.Row=&quot;1&quot;&gt;<br />&lt;Rectangle.Fill&gt;<br />&lt;LinearGradientBrush&gt;<br />&lt;GradientStop Offset=&quot;0&quot; Color=&quot;LightBlue&quot; /&gt;<br />&lt;GradientStop Offset=&quot;0.4&quot; Color=&quot;Blue&quot; /&gt;<br />&lt;GradientStop Offset=&quot;0.8&quot; Color=&quot;Purple&quot; /&gt;<br />&lt;GradientStop Offset=&quot;1.0&quot; Color=&quot;Lavender&quot;/&gt;<br />&lt;/LinearGradientBrush&gt;<br />&lt;/Rectangle.Fill&gt;<br />&lt;/Rectangle&gt;<br />
  • 16. Przykład XAML<br />&lt;TextBlockFontFamily=&quot;Verdana&quot; FontSize=&quot;72„FontStyle=&quot;Italic&quot; FontWeight=&quot;Bold&quot; &gt;<br /> KOALA<br />&lt;TextBlock.Foreground&gt;<br />&lt;ImageBrushImageSource=&quot;Koala.jpg&quot; /&gt;<br />&lt;/TextBlock.Foreground&gt;<br />&lt;/TextBlock&gt;<br />
  • 17. Przykład XAML<br />&lt;TextBlock Text=&quot;Click to win!&quot; TextDecorations=&quot;None&quot;<br />Cursor=&quot;Hand&quot; FontSize=&quot;14&quot; FontWeight=&quot;Bold&quot;<br />MouseEnter=&quot;TextBlock_MouseEnter&quot;<br /> MouseLeave=&quot;TextBlock_MouseLeave&quot;<br /> MouseLeftButtonUp=&quot;TextBlock_MouseLeftButtonUp&quot; /&gt;<br />privatevoidTextBlock_MouseEnter(object sender, MouseEventArgs e)<br />{<br /> ((TextBlock)sender).TextDecorations = TextDecorations.Underline;<br /> ((TextBlock)sender).Foreground = Brushes.Maroon;<br />}<br />privatevoidTextBlock_MouseLeave(object sender, MouseEventArgs e)<br />{<br /> ((TextBlock)sender).TextDecorations = null;<br /> ((TextBlock)sender).Foreground = Brushes.Black;<br />}<br />privatevoidTextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)<br />{<br />MessageBox.Show(&quot;Congratulations!&quot;);<br />}<br />
  • 18. Style<br />&lt;Application.Resources&gt;<br />&lt;StyleTargetType=&quot;Button&quot; x:Key=&quot;GelButton&quot;&gt;<br />&lt;Setter Property=&quot;Margin&quot; Value=&quot;1,2,1,2&quot;/&gt;<br />&lt;Setter Property=&quot;HorizontalAlignment„Value=&quot;Left&quot;/&gt;<br />&lt;Setter Property=&quot;Template&quot;&gt;<br />&lt;Setter.Value&gt;<br /> ...<br />&lt;/Setter.Value&gt;<br />&lt;/Setter&gt;<br />&lt;/Style&gt;<br />&lt;/Application.Resources&gt;<br />&lt;Button Height=&quot;50&quot; Width=&quot;250&quot; Style=&quot;{StaticResource GelButton}&quot; Content=&quot;Button 1&quot;/&gt;<br />
  • 19. Style<br />&lt;Application.Resources&gt;<br />&lt;StyleTargetType=&quot;Button&quot;&gt;<br />&lt;Setter Property=&quot;Margin&quot; Value=&quot;1,2,1,2&quot;/&gt;<br />&lt;Setter Property=&quot;HorizontalAlignment„Value=&quot;Left&quot;/&gt;<br />&lt;Setter Property=&quot;Template&quot;&gt;<br />&lt;Setter.Value&gt;<br /> ...<br />&lt;/Setter.Value&gt;<br />&lt;/Setter&gt;<br />&lt;/Style&gt;<br />&lt;/Application.Resources&gt;<br />&lt;Button Height=&quot;50&quot; Width=&quot;250&quot;Content=&quot;Button 1&quot;/&gt;<br />
  • 20. Data Binding<br />Managed Object<br />ADO.NET Data Source<br />XML Data<br />
  • 21. Data Binding<br />
  • 22. Tryby Bindowania<br />OneWay<br />TwoWay<br />OneWayToSource<br />OneTime<br />Cel<br />Źródło<br />
  • 23. Bindowanie do obiektu<br />namespace MyNamespace<br />{<br />classMyClass<br /> {<br />publicstring ColorName<br /> {<br />get { return&quot;Red&quot;; }<br /> }<br /> }<br />}&lt;DockPanel xmlns:c=&quot;clr-namespace:MyNamespace&quot;&gt;<br />&lt;DockPanel.Resources&gt;<br />&lt;c:MyClass x:Key=&quot;mySource&quot; /&gt;<br />&lt;/DockPanel.Resources&gt;<br />&lt;ButtonBackground=&quot;{Binding Path=ColorName,Source={StaticResourcemySource}}&quot;&gt;<br /> ...<br />&lt;/Button&gt;<br /> &lt;/DockPanel&gt;<br />
  • 24. Bindowanie<br />&lt;DockPanel xmlns:c=&quot;clr-namespace:MyNamespace&quot;&gt;<br />&lt;DockPanel.Resources&gt;...&lt;/DockPanel.Resources&gt;<br />&lt;DockPanel.DataContext&gt;<br />&lt;Binding Source=&quot;{StaticResource mySource}&quot;/&gt;<br />&lt;/DockPanel.DataContext&gt;<br />&lt;Button Background=&quot;{Binding Path=BackColorName}&quot;&gt;<br /> ...<br />&lt;/Button&gt;<br />&lt;TextBox Foreground=&quot;{Binding Path=ForeColorName}&quot;&gt;<br /> ...<br />&lt;/TextBox&gt;<br />&lt;/DockPanel&gt;<br />
  • 25. UpdateTrigger<br />&lt;TextBox Width=&quot;100&quot;&gt;<br />&lt;TextBox.Text&gt;<br />&lt;Binding Source=&quot;{StaticResource myData}&quot;<br /> Path=&quot;ColorName&quot;<br />UpdateSourceTrigger=&quot;PropertyChanged&quot; /&gt;<br />&lt;/TextBox.Text&gt;<br />&lt;/TextBox&gt;<br />Kiedy ma następować aktualizacja?<br /><ul><li>Default
  • 26. Explicit
  • 27. LostFocus
  • 28. PropertyChanged</li></li></ul><li>UpdateTrigger - przykład<br />&lt;Label&gt;Enter a Name:&lt;/Label&gt;<br />&lt;TextBox&gt;<br />&lt;TextBox.Text&gt;<br />&lt;BindingSource=&quot;{StaticResource myDataSource}&quot; Path=&quot;Name&quot; UpdateSourceTrigger= &quot;PropertyChanged&quot; /&gt;<br />&lt;/TextBox.Text&gt;<br />&lt;/TextBox&gt;<br />&lt;Label&gt;The name you entered:&lt;/Label&gt;<br />&lt;TextBlock Text=&quot;{Binding Source= {StaticResourcemyDataSource}, Path = Name}&quot;/&gt;&lt;TextBox Name=&quot;itemNameTextBox&quot; Text=&quot;{Binding Path=ItemName, UpdateSourceTrigger=Explicit}&quot; /&gt;<br />//itemNameTextBox is an instance of a TextBox<br />BindingExpressionbe = itemNameTextBox.GetBindingExpression(TextBox.TextProperty);<br />be.UpdateSource();<br />
  • 29. DataTemplate<br />&lt;DataTemplate x:Key=&quot;myTaskTemplate&quot;&gt;<br />&lt;Border Name=&quot;border&quot; BorderBrush=&quot;Aqua&quot; BorderThickness=&quot;1&quot; Padding=&quot;5&quot; Margin=&quot;5&quot;&gt;<br />&lt;Grid&gt;<br />&lt;Grid.RowDefinitions&gt;<br />&lt;RowDefinition/&gt;<br />&lt;RowDefinition/&gt;<br />&lt;RowDefinition/&gt;<br />&lt;/Grid.RowDefinitions&gt;<br />&lt;Grid.ColumnDefinitions&gt;<br />&lt;ColumnDefinition /&gt;<br />&lt;ColumnDefinition /&gt;<br />&lt;/Grid.ColumnDefinitions&gt;<br />&lt;TextBlockGrid.Row=&quot;0&quot;Grid.Column=&quot;0&quot; Text=&quot;Task Name:&quot;/&gt;<br />&lt;TextBlock Grid.Row=&quot;0&quot; Grid.Column=&quot;l&quot; Text=&quot;{BindingPath=TaskName}&quot;/&gt;<br />&lt;TextBlock Grid.Row=&quot;1&quot; Grid.Column=&quot;0&quot; Text=&quot;Description:&quot; /&gt;<br />&lt;TextBlock Grid.Row=&quot;1&quot;Grid.Column=&quot;1&quot; Text=&quot;{Binding Path.Description}&quot; /&gt;<br />&lt;TextBlock Grid.Row=&quot;2&quot;Grid.Column=&quot;0&quot;Text=&quot;Priority:&quot; /&gt;<br />&lt;TextBlock Grid.Row=&quot;2&quot; Grid.Column=&quot;1&quot; Text=&quot;{BindingPath=Priority}&quot; /&gt;<br />&lt;/Grid&gt;<br />&lt;/Border&gt;<br />&lt;/DataTemplate&gt;&lt;ListBox Width=&quot;400&quot; Margin=&quot;10&quot; ItemsSource=&quot;{Binding Source={StaticResource myTodoList}}&quot;ItemTemplate=&quot;{StaticResource myTaskTemplate}&quot; HorizontalContentAlignment=&quot;Stretch&quot;/&gt;<br />
  • 30. &lt;Border Width=&quot;400&quot; <br /> BorderBrush=&quot;Green&quot; <br /> BorderThickness=&quot;9&quot;&gt;<br /> &lt;StackPanel&gt;<br />&lt;MediaElement Source=&quot;aero.wmv&quot; /&gt;<br /> &lt;Button&gt;Hello&lt;/Button&gt;<br /> &lt;/StackPanel&gt;<br />&lt;/Border&gt;<br />Audio i Wideo<br />Ronnie Saurenmann (WPF)<br />Różne formaty: WMV, MPEG, Some AVIs<br />Synchronizacha z animacjami<br />
  • 31. Grafika 2D, Grafika 3D, Obrazy<br />Ronnie Saurenmann (WPF)<br />Grafika 2D<br />Grafika 3D<br />Obrazy<br />
  • 32. Transformacja i animacja<br />RotateTransform<br />ScaleTransform<br />RenderTransform<br />Efekty: rozmycie, poświata<br />Zmiana każdej właściwości w czasie<br />
  • 33. Dokumenty, drukowanie<br />Użycie kontrolek Windows Forms<br />XAML Browser Applications (XBAPs)<br />Co jeszcze?<br />
  • 34. Expression Blend<br />
  • 35. Nowe kontrolki<br />Datagrid, Ribbon, Visual State Manager<br />WPF Toolkit:http://wpf.codeplex.com/<br />Office UI Licensing Developer Center:<br />http://msdn.microsoft.com/hr-hr/office/aa973809(en-us).aspx<br />
  • 36. Demo<br />Ribbon<br />
  • 37. Łatwe tworzenie GUI<br />Automagiczne przekazywanie wartości<br />Prostota i funkcjonalność<br />Oddzielenie logiki od wyglądu<br />Zachwyt użytkownika<br />Podsumowanie<br />
  • 38. Dziękuję<br />&lt;Canvas Width=&quot;100&quot; Height=&quot;100&quot;&gt;&lt;Ellipse Fill=&quot;Yellow&quot; Stroke=&quot;Black&quot;<br /> StrokeThickness=&quot;7&quot;<br /> Width=&quot;100&quot; Height=&quot;100&quot; /&gt;<br /> &lt;Ellipse Fill=&quot;Black&quot;<br /> Width=&quot;10&quot; Height=&quot;15&quot;<br /> Canvas.Left=&quot;28&quot; Canvas.Top=&quot;28&quot; /&gt;<br />&lt;Ellipse Fill=&quot;Black&quot;<br /> Width=&quot;10&quot; Height=&quot;15&quot;<br /> Canvas.Left=&quot;62&quot; Canvas.Top=&quot;28&quot; /&gt;<br /> &lt;Path Stroke=&quot;Black&quot;<br /> StrokeThickness=&quot;6&quot;<br /> Data=&quot;M 30,60 Q 50,90 70,60&quot; /&gt;<br />&lt;/Canvas&gt;<br />

×