Controlling The Storyboard


   
      
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel>
        <Canvas Width="350" Height="200">
            <Rectangle Canvas.Left="150" Canvas.Top="50" Fill="Aqua" Width="50" Height="150">
                <Rectangle.RenderTransform>
                    <TransformGroup>
                        <RotateTransform x:Name="xform1" Angle="-90" CenterX="0" CenterY="150" />
                    </TransformGroup>
                </Rectangle.RenderTransform>
            </Rectangle>
        </Canvas>

        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Name="btnBegin" Content="Begin" />
            <Button Name="btnPause" Content="Pause" />
            <Button Name="btnResume" Content="Resume" />
            <Button Name="btnStop" Content="Stop" />
            <Button Name="btnSkip" Content="Skip to End" />
            <Button Name="btnCenter" Content="Skip to Center" />
        </StackPanel>

        <StackPanel.Triggers>
            <EventTrigger SourceName="btnBegin" RoutedEvent="Button.Click">
                <BeginStoryboard Name="storybrd">
                    <Storyboard >
                        <DoubleAnimation 
                            Storyboard.TargetName="xform1"
                            Storyboard.TargetProperty="Angle"
                            From="-90" To="0" Duration="0:0:5" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>

            <EventTrigger SourceName="btnPause" RoutedEvent="Button.Click">
                <PauseStoryboard BeginStoryboardName="storybrd" />
            </EventTrigger>

            <EventTrigger SourceName="btnResume" RoutedEvent="Button.Click">
                <ResumeStoryboard BeginStoryboardName="storybrd" />
            </EventTrigger>

            <EventTrigger SourceName="btnStop" RoutedEvent="Button.Click">
                <StopStoryboard BeginStoryboardName="storybrd" />
            </EventTrigger>

            <EventTrigger SourceName="btnSkip" RoutedEvent="Button.Click">
                <SkipStoryboardToFill BeginStoryboardName="storybrd" />
            </EventTrigger>

            <EventTrigger SourceName="btnCenter" RoutedEvent="Button.Click">
                <SeekStoryboard BeginStoryboardName="storybrd"
                                Offset="0:0:5" />
            </EventTrigger>

        </StackPanel.Triggers>
    </StackPanel>
</Page>

   
    
    
    
    
    
     


EventTrigger RoutedEvent=Image.Loaded


   
   
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
      <Image Source="c:image.jpg" Width="200" Height="150" HorizontalAlignment="Left">
        <Image.Clip>
          <EllipseGeometry x:Name="MyEllipseGeometry2"
            RadiusX="100"
            RadiusY="75"
            Center="100,75"/>
        </Image.Clip>
        <Image.Triggers>
          <EventTrigger RoutedEvent="Image.Loaded">
            <BeginStoryboard>
              <Storyboard>
                <DoubleAnimation 
                  Storyboard.TargetName="MyEllipseGeometry2" 
                  Storyboard.TargetProperty="(EllipseGeometry.RadiusX)"
                  From="0" To="150" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True" />
                <DoubleAnimation 
                  Storyboard.TargetName="MyEllipseGeometry2" 
                  Storyboard.TargetProperty="(EllipseGeometry.RadiusY)" 
                  From="0" To="150" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True" />
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
        </Image.Triggers>        
       </Image>
</Window>

   
    
    
     


Animation ProgressBar.


   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ProgBar.Window1"
    Title ="ProgressBar"
    Width="500">

  <StackPanel>
    <Button Content="One" Click="MakeOne"/>
    <StatusBar Name="sbar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom" Background="Beige" >
      <StatusBarItem>
        <TextBlock>StatusBar</TextBlock>
      </StatusBarItem>
    </StatusBar>
  </StackPanel>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;



namespace ProgBar
{

    public partial class Window1 : Window
    {
        
        private void MakeOne(object sender, RoutedEventArgs e)
        {
           sbar.Items.Clear();
           Label lbl = new Label();
           lbl.Background = new LinearGradientBrush(Colors.Pink, Colors.Red, 90);
           lbl.Content = "ProgressBar with three iterations.";
           sbar.Items.Add(lbl);
           ProgressBar progbar = new ProgressBar();
           progbar.Background = Brushes.Gray;
           progbar.Foreground = Brushes.Red;
           progbar.Width = 150;
           progbar.Height = 15;
           Duration duration = new Duration(TimeSpan.FromMilliseconds(2000));
           DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);
           doubleanimation.RepeatBehavior = new RepeatBehavior(3);
           progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
           sbar.Items.Add(progbar);
        } 

     }
}

   
    
     


Create a ProgressBar.


   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ProgBar.Window1"
    Title ="ProgressBar"
    Width="500">

  <StackPanel>
    <Button Content="One" Click="MakeOne"/>
    <StatusBar Name="sbar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom" Background="Beige" >
      <StatusBarItem>
        <TextBlock>StatusBar</TextBlock>
      </StatusBarItem>
    </StatusBar>
  </StackPanel>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;



namespace ProgBar
{

    public partial class Window1 : Window
    {
        
        private void MakeOne(object sender, RoutedEventArgs e)
        {
           sbar.Items.Clear();
           Label lbl = new Label();
           lbl.Background = new LinearGradientBrush(Colors.LightBlue, Colors.SlateBlue, 90);
           lbl.Content = "ProgressBar with one iteration.";
           sbar.Items.Add(lbl);

           ProgressBar progbar = new ProgressBar();
           progbar.IsIndeterminate = false;
           progbar.Orientation = Orientation.Horizontal;
           progbar.Width = 150;
           progbar.Height = 15;
           Duration duration = new Duration(TimeSpan.FromSeconds(10));
           DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);
           progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);

           sbar.Items.Add(progbar);
          } 

     }
}

   
    
     


Add Image to Statusbar

   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="StatusBarSimple.Window1"
    Title ="StatusBar">
  <Window.Resources>
    <Style x:Key="StatusBarSeparatorStyle" TargetType="Separator">
      <Setter Property="Background" Value="LightBlue" />
      <Setter Property="Control.Width" Value="1"/>
      <Setter Property="Control.Height" Value="20"/>
    </Style>    
  </Window.Resources>
        <StatusBar Name="sbar" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" 
                   VerticalAlignment="Bottom" Background="Beige" > 
             <StatusBarItem>
                <Button Content="click" Click="MakeProgressBar"/>
             </StatusBarItem>
             <StatusBarItem>
               <Separator Style="{StaticResource StatusBarSeparatorStyle}"/>
             </StatusBarItem>
        </StatusBar>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace StatusBarSimple
{
    public partial class Window1 : Window
    {
        private void MakeProgressBar(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            DockPanel dpanel = new DockPanel();
            TextBlock txtb = new TextBlock();
            txtb.Text = "Printing  ";
            dpanel.Children.Add(txtb);
            Image printImage = new Image();
            printImage.Width = 16;
            printImage.Height = 16;
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"pack://application:,,,/images/print.bmp");
            bi.EndInit();
            printImage.Source = bi;
            dpanel.Children.Add(printImage);
            TextBlock txtb2 = new TextBlock();
            txtb2.Text = "  5pgs";
            dpanel.Children.Add(txtb2);
            StatusBarItem sbi = new StatusBarItem();
            sbi.Content = dpanel;
            sbi.HorizontalAlignment = HorizontalAlignment.Right;
            ToolTip ttp = new ToolTip();
            ttp.Content = "Sent to printer.";
            sbi.ToolTip = (ttp);
            sbar.Items.Add(sbi);
        }
    }
}

   
    
     


Make Group onto Statusbar


   
  
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="StatusBarSimple.Window1"
    Title ="StatusBar">
  <Window.Resources>
    <Style x:Key="StatusBarSeparatorStyle" TargetType="Separator">
      <Setter Property="Background" Value="LightBlue" />
      <Setter Property="Control.Width" Value="1"/>
      <Setter Property="Control.Height" Value="20"/>
    </Style>    
  </Window.Resources>
        <StatusBar Name="sbar" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" 
                   VerticalAlignment="Bottom" Background="Beige" > 
             <StatusBarItem>
                <Button Content="click" Click="MakeProgressBar"/>
             </StatusBarItem>
             <StatusBarItem>
               <Separator Style="{StaticResource StatusBarSeparatorStyle}"/>
             </StatusBarItem>
        </StatusBar>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace StatusBarSimple
{
    public partial class Window1 : Window
    {
        private void MakeProgressBar(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            Image helpImage = new Image();
            helpImage.Width = 16;
            helpImage.Height = 16;
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"pack://application:,,,/images/help.bmp");
            bi.EndInit();
            helpImage.Source = bi;
            ToolTip ttp = new ToolTip();
            ttp.Content = "HELP";
            helpImage.ToolTip = (ttp);
            sbar.Items.Add(helpImage);

            Separator sp = new Separator();
            sp.Style = (Style)FindResource("StatusBarSeparatorStyle");
            sbar.Items.Add(sp);

            Image printImage = new Image();
            printImage.Width = 16;
            printImage.Height = 16;
            BitmapImage bi_print = new BitmapImage();
            bi_print.BeginInit();
            bi_print.UriSource = new Uri(@"pack://application:,,,/images/print.bmp");
            bi_print.EndInit();
            printImage.Source = bi_print;
            ToolTip ttp_print = new ToolTip();
            ttp.Content = "Sent to printer.";
            printImage.ToolTip = (ttp_print);
            sbar.Items.Add(printImage);
        }
    }
}

   
    
     


Put Image with tooltip onto statusbar


   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="StatusBarSimple.Window1"
    Title ="StatusBar">
  <Window.Resources>
    <Style x:Key="StatusBarSeparatorStyle" TargetType="Separator">
      <Setter Property="Background" Value="LightBlue" />
      <Setter Property="Control.Width" Value="1"/>
      <Setter Property="Control.Height" Value="20"/>
    </Style>    
  </Window.Resources>
        <StatusBar Name="sbar" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" 
                   VerticalAlignment="Bottom" Background="Beige" > 
             <StatusBarItem>
               <TextBlock>Ready</TextBlock>
             </StatusBarItem>
             <StatusBarItem>
               <Separator Style="{StaticResource StatusBarSeparatorStyle}"/>
             </StatusBarItem>
        </StatusBar>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace StatusBarSimple
{
    public partial class Window1 : Window
    {
        private void MakeProgressBar(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            Image helpImage = new Image();
            helpImage.Width = 16;
            helpImage.Height = 16;
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri(@"pack://application:,,,/help.bmp");
            bi.EndInit();
            helpImage.Source = bi;
            ToolTip ttp = new ToolTip();
            ttp.Content = "HELP";
            helpImage.ToolTip = (ttp);
            sbar.Items.Add(helpImage);
        }
    }
}