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?
This is due to StatusBar
using a DockPanel
to lay out its children by default. Please see my question and answer here.
You will need to use a Grid. A DockPanel or StackPanel will not suffice for you. Try:
<Grid>
<StatusBar Name="StatusBarMain" Height="30" HorizontalAlignment="Stretch">
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With