Multicolored Gradient


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>
    <Rectangle Width="150" Height="100" Grid.Row="4" Margin="5">
      <Rectangle.Fill>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
          <GradientStop Color="Yellow" Offset="0.0" />
          <GradientStop Color="Red" Offset="0.25" />
          <GradientStop Color="Blue" Offset="0.75" />
          <GradientStop Color="LimeGreen" Offset="1.0" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="5">Multicolored Gradient</TextBlock>


  </Canvas>
</Page>

   
    
    
    
    
     


Reflected Gradient


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>

    <Rectangle Width="150" Height="100" Grid.Row="3" Margin="5">
      <Rectangle.Fill>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,0.5" SpreadMethod="Reflect">
          <GradientStop Color="Blue" Offset="0"/>
          <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="5">Reflected Gradient</TextBlock>
    
  </Canvas>
</Page>

   
    
    
    
    
     


Horizontal Linear Gradient and GradientStop


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>

    <Rectangle Width="150" Height="100" Grid.Row="2" Margin="5">
      <Rectangle.Fill>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
          <GradientStop Color="Blue" Offset="0"/>
          <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="5">Horizontal Linear Gradient</TextBlock>

  </Canvas>
</Page>

   
    
    
    
    
     


Resource Lookup


   
     

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Orientation="Horizontal">

    <StackPanel.Resources>
        <SolidColorBrush x:Key="brushText" Color="Blue" />
    </StackPanel.Resources>

    <StackPanel>
        <StackPanel.Resources>
            <SolidColorBrush x:Key="brushText" Color="Red" />
        </StackPanel.Resources>

        <Button HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                Margin="24"
                Foreground="{StaticResource brushText}">
            Button with Red text
        </Button>
    </StackPanel>

    <StackPanel>
        <Button HorizontalAlignment="Center" 
                VerticalAlignment="Center" 
                Margin="24"
                Foreground="{StaticResource brushText}">
            Button with Blue text
        </Button>
    </StackPanel>

</StackPanel>

   
    
    
    
    
     


Discrete Point Jumps


   
     

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Path Fill="Red">
        <Path.Data>
            <EllipseGeometry x:Name="elips" RadiusX="24" RadiusY="24" />
        </Path.Data>
    </Path>

    <Canvas.Triggers>
        <EventTrigger RoutedEvent="Canvas.Loaded">
            <BeginStoryboard>
                <Storyboard TargetName="elips" TargetProperty="Center">
                    <PointAnimationUsingKeyFrames Duration="0:0:4"
                                                  RepeatBehavior="Forever">
                        <DiscretePointKeyFrame KeyTime="0:0:0" Value="288 96" />
                        <DiscretePointKeyFrame KeyTime="0:0:3" Value="96 288" />
                    </PointAnimationUsingKeyFrames>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Canvas.Triggers>
</Canvas>

   
    
    
    
    
     


Animated Text Transform


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <TextBlock Text="XAML" FontSize="144pt" FontFamily="Arial Black"
               HorizontalAlignment="Center" VerticalAlignment="Center"
               RenderTransformOrigin="0.5 0.5">

        <TextBlock.RenderTransform>
            <TransformGroup>
                <ScaleTransform x:Name="xformScale" />
                <RotateTransform x:Name="xformRotate" />
            </TransformGroup>
        </TextBlock.RenderTransform>

        <TextBlock.Triggers>
            <EventTrigger RoutedEvent="TextBlock.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="xformScale"
                                         Storyboard.TargetProperty="ScaleX"
                                         From="1" To="-1" Duration="0:0:3" 
                                         AutoReverse="True"
                                         RepeatBehavior="Forever" />

                        <DoubleAnimation Storyboard.TargetName="xformRotate"
                                         Storyboard.TargetProperty="Angle"
                                         From="0" To="360" Duration="0:0:5" 
                                         RepeatBehavior="Forever" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </TextBlock.Triggers>
    </TextBlock>
</Page>

   
    
    
    
    
     


Multiple Sounds


   
     

<Window x:Class="SoundAndVideo.MultipleSounds"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MultipleSounds" Height="300" Width="300">
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
      </Grid.RowDefinitions>
      <MediaElement x:Name="media1" Volume="0.25"></MediaElement>
      <MediaElement x:Name="media2" Volume="1"></MediaElement>
      <Button>
        <Button.Content>Click.</Button.Content>
        <Button.Triggers>
          <EventTrigger RoutedEvent="Button.Click">
            <EventTrigger.Actions>
            <BeginStoryboard>
              <Storyboard>
                <MediaTimeline Source="c:song.mp3" Storyboard.TargetName="media1"></MediaTimeline>
              </Storyboard>
            </BeginStoryboard>
            </EventTrigger.Actions>
          </EventTrigger>
        </Button.Triggers>
      </Button>

      <Button Grid.Row="1">
        <Button.Content >wav</Button.Content>
        <Button.Triggers>
          <EventTrigger RoutedEvent="Button.Click">
            <EventTrigger.Actions>
              <BeginStoryboard>
                <Storyboard>
                  <MediaTimeline Source="c:song.wav" Storyboard.TargetName="media2"></MediaTimeline>
                </Storyboard>
              </BeginStoryboard>
            </EventTrigger.Actions>
          </EventTrigger>
        </Button.Triggers>
      </Button>
    </Grid>
</Window>