Share via


How to: Create a StatusBar

A StatusBar is a horizontal window at the bottom of a parent window in which an application can display various kinds of status information.

Example

The following example shows how to define a StatusBar by using Extensible Application Markup Language (XAML) and how to add a ProgressBar by using code.

<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>
private void MakeProgressBar(object sender, RoutedEventArgs e)
{
  sbar.Items.Clear();
  TextBlock txtb = new TextBlock();
  txtb.Text = "Progress of download.";
  sbar.Items.Add(txtb);
  ProgressBar progressbar = new ProgressBar();
  Duration duration = new Duration(TimeSpan.FromSeconds(10));
  DoubleAnimation doubleanimation = 
                             new DoubleAnimation(100.0, duration);
  progressbar.BeginAnimation(ProgressBar.ValueProperty, 
                             doubleanimation);
  ToolTip ttprogbar = new ToolTip();
  ttprogbar.Content = "Shows the progress of a download.";
  progressbar.ToolTip = (ttprogbar);
  sbar.Items.Add(progressbar);
} 

The following example shows how to add two Image controls that are separated by a Separator control.

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);

For the complete sample, see StatusBar Sample.

See Also

Reference

StatusBar
StatusBarItem

Concepts

StatusBar Overview

Other Resources

StatusBar Sample