What is the point of the StatusBarItem class in WPF? What is the point of the StatusBarItem class in WPF? wpf wpf

What is the point of the StatusBarItem class in WPF?


A StatusBar is an ItemsControl. All ItemsControls have a container class. For ListBoxes, it's ListBoxItem. For StatusBar, it's StatusBarItem. If you don't explicitly wrap your item in a StatusBarItem, it will be implicitly wrapped in one for you.

If you need to set properties of an ItemsControl's containers, you can use the ItemContainerStyle property:

<StatusBar>    <TextBlock>One</TextBlock>    <TextBlock>Two</TextBlock>    <TextBlock>Three</TextBlock>    <StatusBar.ItemContainerStyle>        <Style TargetType="StatusBarItem">            <Setter Property="HorizontalAlignment" Value="Right"/>        </Style>    </StatusBar.ItemContainerStyle></StatusBar>

Finally, note that the StatusBar uses a DockPanel by default to lay out its children. This can be frustrating when you're doing intricate layouts. See my blog post here on how to swap it out for a Grid.