Status Bar Control: WPF

September 16, 2013 , , , 1 Comments

As the name implies, this control is used to show the status of our progress in our application. The status may be like line/column no. in Notepad, page no. in MS Word, or some text in visual studio. It is very easy to add a status bar in our WPF applications.

Just drag-n-drop the Status bar control on the window, it will display a horizontal bar on the window. It can contains strings, images or other containers like panels. A single item can be added using StatusBarItem in the control. The following XAML code will be used to add a status bar in a window.
<StatusBar Name="statusBar" VerticalAlignment="Bottom">
<StatusBarItem Name="statusBarItem">Value Inserted</StatusBarItem>          
</StatusBar>

In the above code the status bar has been placed on bottom by using VerticalAlignment property. When we run the code, it will add a status bar as shown in following image:

status Bar control introduction in WPF

To add a progress bar control with above string, just use the following code:
<StatusBar Name="statusBar" VerticalAlignment="Bottom">
<StatusBarItem Name="statusBarItem">Value Inserted</StatusBarItem>
<ProgressBar Width="150" Height="20" Name="progressBar" Value="45"
HorizontalAlignment="Right"></ProgressBar>
</StatusBar>

When we run the code, it will display a string on left with a progress bar on right side of the window.

Status bar control with string and progress bar in WPF

Subhash Sharma

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

1 comment: