Reputation: 159
I want to have Image which in centered inside StatusBar and DockPanel which is align to right in StatusBar
<StatusBar VerticalAlignment="Bottom" Height="30">
<StatusBarItem HorizontalAlignment="Center" >
<Image />
</StatusBarItem>
<StatusBarItem HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<TextBlock />
<Controls:ProgressRing />
</StackPanel>
</StatusBarItem >
</StatusBar>
I have above code unfortunately it's not working , StackPanel is correctly alight to right but Image is alight to left...
Upvotes: 0
Views: 2005
Reputation: 1732
The StatusBar
uses a DockPanel
to position the StatusBarItems
which is not very convenient when you have several items.
To circumvent your issue, you can create your own layout in the ItemsPanelTemplate
, for instance, a 3 columns Grid
:
Place your image in the center of the middle column, and place your custom control on the right of the 3rd column.
<StatusBar VerticalAlignment="Bottom" Height="30">
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="1" HorizontalAlignment="Center">
<Image />
</StatusBarItem>
<StatusBarItem Grid.Column="2" HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<TextBlock />
<Controls:ProgressRing />
</StackPanel>
</StatusBarItem >
</StatusBar>
Upvotes: 4