SolidColorBrush's Color property is specified using one of the predefined colors defined by the System.Windows.Media.Colors class

image_pdfimage_print


   
 

<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
      <Window.Resources>
        <Style TargetType="{x:Type Rectangle}">
          
          <!-- Gives all the rectangles in this panel a white stroke. -->
          <Setter Property="Stroke" Value="White"/>
          <Setter Property="StrokeThickness" Value="1"/>
        </Style>
      </Window.Resources>
    <Canvas>

      <Rectangle Width="50" Height="50">
        <Rectangle.Fill>
          <SolidColorBrush Color="Blue" />
        </Rectangle.Fill>
      </Rectangle>

    </Canvas>
</Window>

   
     


SolidColorBrush's color is specified using 3-digit hexadecimal notation.

image_pdfimage_print


   
 
            

<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
      <Window.Resources>
        <Style TargetType="{x:Type Rectangle}">
          
          <!-- Gives all the rectangles in this panel a white stroke. -->
          <Setter Property="Stroke" Value="White"/>
          <Setter Property="StrokeThickness" Value="1"/>
        </Style>
      </Window.Resources>
    <Canvas>


      <Rectangle Width="50" Height="50">
        <Rectangle.Fill>
          <SolidColorBrush Color="#00F" />
        </Rectangle.Fill>
      </Rectangle>

    </Canvas>
</Window>

   
     


SolidColorBrush's color is specified using 6-digit hexadecimal notation.

image_pdfimage_print


   
 

<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
      <Window.Resources>
        <Style TargetType="{x:Type Rectangle}">
          
          <!-- Gives all the rectangles in this panel a white stroke. -->
          <Setter Property="Stroke" Value="White"/>
          <Setter Property="StrokeThickness" Value="1"/>
        </Style>
      </Window.Resources>
    <Canvas>


      <Rectangle Width="50" Height="50">
        <Rectangle.Fill>
          <SolidColorBrush Color="#0000FF" />
        </Rectangle.Fill>
      </Rectangle>

    </Canvas>
</Window>

   
     


SolidColorBrush's color is specified using 8-digit hexadecimal notation.

image_pdfimage_print


   
 

<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
      <Window.Resources>
        <Style TargetType="{x:Type Rectangle}">
          
          <!-- Gives all the rectangles in this panel a white stroke. -->
          <Setter Property="Stroke" Value="White"/>
          <Setter Property="StrokeThickness" Value="1"/>
        </Style>
      </Window.Resources>
    <Canvas>


      <Rectangle Width="50" Height="50">
        <Rectangle.Fill>
          <SolidColorBrush Color="#FF0000FF" />
        </Rectangle.Fill>
      </Rectangle>

    </Canvas>
</Window>

   
     


Sound Player Action demo

image_pdfimage_print
   
 

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  <Button>A Button With Sounds
    <Button.Triggers>
      <EventTrigger RoutedEvent="Button.Click">
        <EventTrigger.Actions>
          <SoundPlayerAction Source="click.wav"/>
        </EventTrigger.Actions>
      </EventTrigger>
      <EventTrigger RoutedEvent="Button.MouseEnter">
        <EventTrigger.Actions>
          <SoundPlayerAction Source="hover.wav"/>
        </EventTrigger.Actions>
      </EventTrigger>
    </Button.Triggers>
  </Button>
</Canvas>

   
     


Play audio through event trigger

image_pdfimage_print
   
 
<Window x:Class="SoundAndVideo.SoundPlayerTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SoundPlayerTest" Height="300" Width="300">
    <StackPanel>
        <Button>
        <Button.Content>Play Through Wrapper</Button.Content>
        <Button.Style>
          <Style>
            <Style.Triggers>
              <EventTrigger RoutedEvent="Button.Click">
                <EventTrigger.Actions>
                  <SoundPlayerAction Source="test.wav"></SoundPlayerAction>
                </EventTrigger.Actions>
              </EventTrigger>
            </Style.Triggers>
          </Style>
        </Button.Style>
      </Button>
    </StackPanel>
</Window>

   
     


Nested Span elements

image_pdfimage_print


   
      
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Center" VerticalAlignment="Center">


<TextBlock>
  <Span FontFamily="Cambria">
    This uses <Span FontWeight="Bold">a
    <Span FontStyle="Italic">mixture</Span> of</Span> styles.
  </Span>
</TextBlock>


</Page>