Introduction
Here I am sharing a small story in which we are discussing that how to use StatusBar in WPF. We have taken a CheckBox, Label and StatusBar control, when we checked the CheckBox. StatusBar will display in active and running state, when unchecked it will be in inactive and stopped state.
Getting Started
- Simply create a new WPF application.
- Drag a Grid, StatusBar, CheckBox and Label control on your MainWindow. Your window will look like below.

- Your MainWindow.xaml page will look like below.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="271" Width="327">
<Grid>
<StatusBar Height="30" Name="Stbr" VerticalAlignment="Bottom">
<StatusBarItem>
<Label Name="labelStbr" Content="InActive" />
</StatusBarItem>
<StatusBarItem HorizontalAlignment="Right" >
<Label Name="labelRunning" Content="Stopped" />
</StatusBarItem>
</StatusBar>
<CheckBox Height="16" HorizontalAlignment="Left" Margin="10,10,0,0" Name="checkOnOff"
VerticalAlignment="Top" Width="120" Content="state" ToolTip="Click to activate">
<CheckBox.Triggers>
<EventTrigger RoutedEvent="CheckBox.Checked">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<StringAnimationUsingKeyFrames Storyboard.TargetName="labelStbr"
Storyboard.TargetProperty="Content">
<StringAnimationUsingKeyFrames.KeyFrames>
<DiscreteStringKeyFrame Value="Active" KeyTime="0:0:0" />
</StringAnimationUsingKeyFrames.KeyFrames>
</StringAnimationUsingKeyFrames>
<StringAnimationUsingKeyFrames
Storyboard.TargetName="labelRunning"
Storyboard.TargetProperty="Content">
<StringAnimationUsingKeyFrames.KeyFrames>
<DiscreteStringKeyFrame Value="Running..." KeyTime="0:0:0" />
</StringAnimationUsingKeyFrames.KeyFrames>
</StringAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<StringAnimationUsingKeyFrames
Storyboard.TargetName="labelStbr"
Storyboard.TargetProperty="Content">
<StringAnimationUsingKeyFrames.KeyFrames>
<DiscreteStringKeyFrame Value="InActive" KeyTime="0:0:0" />
</StringAnimationUsingKeyFrames.KeyFrames>
</StringAnimationUsingKeyFrames>
<StringAnimationUsingKeyFrames
Storyboard.TargetName="labelRunning"
Storyboard.TargetProperty="Content">
<StringAnimationUsingKeyFrames.KeyFrames>
<DiscreteStringKeyFrame Value="Stopped" KeyTime="0:0:0" />
</StringAnimationUsingKeyFrames.KeyFrames>
</StringAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</CheckBox.Triggers>
</CheckBox>
</Grid>
</Window>
- Now run your application
Output



Summary
In this story you learned that how to use StatusBar to display state.