tags:

views:

73

answers:

1

Hey guys,

I have a status bar that I'd like to house a TextBlock docked to the left and a ProgressBar filling the remaining width. In all my other experience with the WPF ProgressBar it will fill its given container, however in this situation it doesn't auto-size at all, it just appears as a tiny circle. Setting its height and width manually work fine, but I'd like it to scale to the remaining width of the StatusBar.

Here's my XAML for the StatusBar:

<StatusBar DockPanel.Dock="Bottom" Height="25">
    <StatusBarItem DockPanel.Dock="Left">
        <TextBlock x:Name="lblStatus"  Margin="5,0,0,0"/>
    </StatusBarItem>
    <StatusBarItem>
        <ProgressBar x:Name="pgbStatus" />
    </StatusBarItem>
</StatusBar>
+1  A: 

You just need one extra attribute: HorizontalContentAlignment="Stretch" on the StatusBarItem. Thus:

<StatusBar DockPanel.Dock="Bottom" Height="25">
  <StatusBarItem DockPanel.Dock="Left">
    <TextBlock x:Name="lblStatus" Margin="5,0,0,0"/>
  </StatusBarItem>
  <StatusBarItem HorizontalContentAlignment="Stretch">  <!-- Note extra attribute -->
    <ProgressBar x:Name="pgbStatus" />
  </StatusBarItem>
</StatusBar>
itowlson
Beautiful, thank you!
Mel Green