Search code examples
c#wpfprogress-barstatusbar

WPF ProgressBar in StatusBar won't stretch


New to WPF & I have the following XAML

<Window x:Class="Wpf.RossKiosk.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Topmost="True" WindowStartupLocation="CenterScreen" WindowState="Maximized" ResizeMode="NoResize" WindowStyle="None">
<DockPanel LastChildFill="True">

    <StatusBar Name="StatusBarMain" Height="30"  DockPanel.Dock="Bottom">
        <StatusBarItem HorizontalContentAlignment="Left">
            <TextBlock x:Name="TextBlockStatus" Margin="5,0,0,0" />
        </StatusBarItem>
        <StatusBarItem HorizontalContentAlignment="Stretch">
            <ProgressBar x:Name="ProgressBarMain" IsIndeterminate="True" Height="15" />
        </StatusBarItem>
        <StatusBarItem HorizontalContentAlignment="Right">
            <TextBlock x:Name="TextBlockInfo" Margin="5,0,0,0" TextAlignment="Right" />
        </StatusBarItem>
    </StatusBar>

    <Grid Name="GridMain">

        <!-- Dynamically Created buttons -->


    </Grid>


</DockPanel>

I want the ProgressBar to fill the centre portion of the StatusBar but it only shows itself a few pixels in width. Any ideas?


Solution

  • This is due to StatusBar using a DockPanel to lay out its children by default. Please see my question and answer here.