Data Classes
- /// <summary>
- /// The cartoon character.
- /// </summary>
- public class CartoonCharacter
- {
- /// <summary>
- /// Gets or sets the forename.
- /// </summary>
- /// <value>The forename.</value>
- public string Forename { get; set; }
- }
- /// <summary>
- /// The flintstone.
- /// </summary>
- public class Flintstone : CartoonCharacter { }
- /// <summary>
- /// The griffin.
- /// </summary>
- public class Griffin : CartoonCharacter { }
- /// <summary>
- /// The simpson.
- /// </summary>
- public class Simpson : CartoonCharacter { }
XAML
- <Grid x:Name="LayoutRoot"
- Background="White">
- <Grid.Resources>
- <Style x:Key="SimpsonStyle"
- TargetType="TextBlock">
- <Setter Property="FontFamily" Value="Comic Sans MS" />
- <Setter Property="FontSize" Value="16" />
- <Setter Property="Foreground" Value="Blue" />
- <Setter Property="FontStyle" Value="Italic" />
- </Style>
- <DataTemplate DataType="this:Simpson">
- <Border Background="Yellow">
- <StackPanel Orientation="Horizontal">
- <TextBlock Style="{StaticResource SimpsonStyle}"
- Text="{Binding Forename}" />
- <TextBlock Margin="5,0,0,0"
- Style="{StaticResource SimpsonStyle}"
- Text="Simpson" />
- </StackPanel>
- </Border>
- </DataTemplate>
- <DataTemplate DataType="this:Flintstone">
- <Border Background="Orange">
- <Border.RenderTransform>
- <TransformGroup>
- <SkewTransform AngleX="-20" />
- <ScaleTransform ScaleX="2"
- ScaleY="0.75" />
- <TranslateTransform X="30" />
- </TransformGroup>
- </Border.RenderTransform>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding Forename}" />
- <TextBlock Margin="5,0,0,0"
- Text="Flintstone" />
- </StackPanel>
- </Border>
- </DataTemplate>
- <DataTemplate DataType="this:Griffin">
- <Border BorderBrush="DarkSlateBlue" BorderThickness="2">
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding Forename}" FontSize="18">
- <TextBlock.Effect>
- <BlurEffect />
- </TextBlock.Effect>
- </TextBlock>
- <TextBlock Margin="5,0,0,0"
- FontSize="22" CharacterSpacing="5"
- Text="Griffin">
- <TextBlock.Effect>
- <DropShadowEffect />
- </TextBlock.Effect>
- </TextBlock>
- </StackPanel>
- </Border>
- </DataTemplate>
- </Grid.Resources>
- <ListBox x:Name="CartoonCharactersListBox"
- Margin="50,20"
- BorderBrush="Blue"
- BorderThickness="2"
- ItemsSource="{Binding}" />
- </Grid>
Yeugh!!
No comments:
Post a Comment