<...">

Why won't WPF reach the limit?

This is my original code:

<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal"> <ProgressBar Height="23" Name="searchProgressBar" Foreground="Blue" BorderBrush="#00000000" BorderThickness="1" VerticalAlignment="Top" HorizontalAlignment="Stretch"/> <TextBlock Text="asdf" Height="23" Name="progressTextBlock" VerticalAlignment="Top" Foreground="Red" HorizontalAlignment="Right"/> </StackPanel> 

The progress indicator was very small, perhaps 2 or 3 pixels wide, after which there was a text block and empty space after it. So I tried to explicitly bind the elements to the sides:

 <DockPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" > <ProgressBar DockPanel.Dock="Left" Height="23" Name="searchProgressBar" Foreground="Blue" BorderBrush="#00000000" BorderThickness="1" VerticalAlignment="Top" /> <TextBlock DockPanel.Dock="Right" Text="asdf" Height="23" Name="progressTextBlock" VerticalAlignment="Top" Foreground="Red" HorizontalAlignment="Right"/> </DockPanel> 

To no avail. I also tried to change each solution by setting HorizontalAlignment="Stretch" to a progress bar, but no changes occurred. How do I stretch it to fill all the space after a text block?

+6
source share
2 answers

Remove DockPanel.Dock="Left" from the ProgressBar and switch the order of the controls:

 <DockPanel> <TextBlock DockPanel.Dock="Right" Height="23" VerticalAlignment="Top" HorizontalAlignment="Right"/> <ProgressBar Height="23" VerticalAlignment="Top" /> </DockPanel> 

By default, the DockPanel has the DockPanel property set to true , which will make the ProgressBar available.

+4
source

ahh I see what you are trying to do. This is probably the best place to use a grid with two column definitions. The first (left) definition of a column with width = "*" and the second (right) with a width set to "Width =" Auto ". For more information about vs * cars, see http://social.msdn.microsoft.com / Forums / en-US / wpf / thread / 9a7e6591-1fae-4295-b68a-be97e8e53d06 /

+1
source

All Articles