Live Chat Icon For mobile
Live Chat Icon

WPF FAQ - StatusBar

Find answers for the most frequently asked questions
Expand All Collapse All

You cannot place controls into a StatusBar control in the Designer. However, you can add any number of controls to the StatusBar programmatically through it’s ‘Controls’ property. After adding the controls, set their Visible, Location, Bounds and other properties.

Here’s a sample method that could be called in a form’s constructor after the ’InitializeComponent’.


 private void AddStatusBarControls(StatusBar sb)
            ProgressBar pb = new ProgressBar();

            pb.Visible = true;
            pb.Bounds = new Rectangle(sb.Width / 4, 4, sb.Width / 2, sb.Height - 8);
            pb.Anchor = AnchorStyles.Left | AnchorStyles.Right;


StatusBar uses a DockPanel as an item template and docks all the items in the control to the left except for the last item. The last item takes the rest of the space in the statusbar. To have a custom layout for the statusbar control, you can change the DockPanel to a StackPanel, WrapPanel etc. You can also align the items in the statusbar using the DockPanel.Dock property for each statusbar item.

The following lines of code are used to change the alignment of the statusbar items.


<StatusBar Height='30' VerticalAlignment='Bottom' Background='Azure'>
<StatusBarItem DockPanel.Dock='Right'>
      	<TextBlock Text='Welcome to WPF!!'/>
      	<TextBlock Text='Hello World! '/>

private void statusBar1_PanelClick(object sender, 
System.Windows.Forms.StatusBarPanelClickEventArgs e)
   switch (statusBar1.Panels.IndexOf(e.StatusBarPanel))
      case 0 :
         MessageBox.Show('You have clicked Panel One.');
      case 1 :
         MessageBox.Show('You have clicked Panel Two.');
//Place the following code in the form’s constructor to register the event handler.

   this.statusBar1.PanelClick += new 


Share with

Couldn't find the FAQs you're looking for?

Please submit your question and answer.