Toni
Toni

Reputation: 1585

WPF XAML status bar items align to right

I have these items inside a status bar and I can't align the progress bar to the right. All items are inside a grid. Please Help.

<Grid>
    <StatusBar HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="30"
        x:Name="StatusBarBase">
        <TextBlock Text="{DynamicResource loading}" x:Name="progressBarTextBlock"/>
        <Separator/>
        <ProgressBar Width="100" Height="20" x:Name="progressBar"/>
    </StatusBar>
</Grid>

Required result.

Upvotes: 1

Views: 767

Answers (1)

user2250152
user2250152

Reputation: 20843

StatusBar is an ItemsControl. Items in a StatusBar are defined as StatusBarItem objects.

Place your items in StatusBarItem and set the horizontal alignment for StatusBarItem with ProgressBar.

<!-- Edited indentation to make code more readable. -->

<StatusBar HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="30" x:Name="StatusBarBase">
    <StatusBarItem>
        <TextBlock Text="Text" x:Name="progressBarTextBlock"/>
    </StatusBarItem>            
    <Separator />
    <StatusBarItem HorizontalAlignment="Right">
        <ProgressBar Width="100" Height="20" x:Name="progressBar"/>
    </StatusBarItem>            
</StatusBar>

Upvotes: 3

Related Questions