I am using a progress bar to represents the transferred data in a WPF application.
A new progress bar (and a new item into the ListBox) will be instantiated dynamically a for each transfer.
I have a XAML GUI problem: the size of the progres bar is fixed and doesn't stretch with the width of the window. Each elements of the windows reacts correctly at window resize except for the progres bar which width still remains fixed.
How I can made my progress bar width automatically fitted into the ListBox?
Here is the portion of XAML code relative to the ListBox and the progress bar template:
<ListBox Grid.Column="2" Name="TransfersList" Margin="0.111,0,-0.222,34.889" ItemsSource="{Binding DataTx}"
SelectionChanged="TransfersList_SelectionChanged" Grid.Row="1" Grid.ColumnSpan="2">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Ottieni informazioni" Click="GetInfo" />
<MenuItem Header="Metti in pausa" Click="PauseTransfer" />
<MenuItem Header="Riprendi trasferimento" Click="ResumeTransfer" />
<MenuItem Header="Annulla trasferimento" Click="StopTransfer" />
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<ProgressBar Height="20" Minimum="0" Maximum="100" Name="gasparino_il_carbonaro"
Value="{Binding PbStatus}" Width="177" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I tried also with (on the ProgressBar template):
- HorizontalAlignment="Stretch"
- HorizontalContentAlignment="Stretch"
but with the same following result:
Note that the progress bar item results correctly stretched, but the bar (grey and gree visible part) results compressed (see red arrow).
HorizontalAlignment="Stretch"
on theProgressBar
? – José PedroHorizontalContentAlignment="Stretch"
on theListBox
? – José Pedro