If you want full control over your status bar's XAML layout, use the StatusbarHelper instead of the StatusbarControl. The helper provides the logic for updating icons and text, but requires you to provide the UI elements.
Requirements for Custom Layouts
- An Icon Image control: An
Image control that the helper can update. - A Main TextBlock: A
TextBlock control for the primary status message. - Resource Dictionary: If using default icons, you must include
icons.xaml in your Window or App resources. - Fixed Dimensions: For best visual results, use a fixed height for the
StatusBar and the icon (13-15px recommended) to prevent layout flickering during animations.
Implementation Steps
- Define your custom
StatusBar in XAML with named Image and TextBlock controls. - Create a property in your Window/Control to hold the
StatusbarHelper instance. - Initialize the helper in your constructor, passing the named text and icon controls.
<!-- 1. Add icon resources -->
<Window.Resources>
<ResourceDictionary Source="pack://application:,,,/Westwind.Wpf.Statusbar;component/Assets/icons.xaml" />
</Window.Resources>
<!-- 2. Define custom layout -->
<StatusBar Height="30" VerticalAlignment="Bottom" HorizontalAlignment="Stretch">
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="0" Margin="2,1,0,0">
<Image x:Name="StatusIcon" Source="{StaticResource circle_greenDrawingImage}" Height="14" />
</StatusBarItem>
<StatusBarItem Grid.Column="1">
<TextBlock Name="StatusText">Ready</TextBlock>
</StatusBarItem>
<StatusBarItem Grid.Column="2">
<ContentControl Name="StatusCenter" x:FieldModifier="public" />
</StatusBarItem>
<StatusBarItem Grid.Column="3">
<ContentControl x:Name="StatusRight" x:FieldModifier="public" />
</StatusBarItem>
</StatusBar>