• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Windows Presentation Foundation
 

Windows Presentation Foundation

on

  • 3,573 views

 

Statistics

Views

Total Views
3,573
Views on SlideShare
2,597
Embed Views
976

Actions

Likes
0
Downloads
26
Comments
0

5 Embeds 976

http://eastgroup.pl 966
http://www.eastgroup.pl 4
http://webcache.googleusercontent.com 3
http://www.slideshare.net 2
http://213.184.18.148 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Windows Presentation Foundation Windows Presentation Foundation Presentation Transcript

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