title: XAML WPF Progressbar into ListBox width auto strecht with the window resize
body: <p>I am using a progress bar to represents the transferred data in a WPF application.</p>
  
  <p>A new progress bar (and a new item into the ListBox) will be instantiated dynamically a for each transfer.</p>
  
  <p>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.</p>
  
  <p>How I can made my progress bar width automatically fitted into the ListBox?</p>
  
  <p>Here is the portion of XAML code relative to the ListBox and the progress bar template:</p>
  
  <pre><code>    &lt;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"&gt;
          &lt;ListBox.ContextMenu&gt;
              &lt;ContextMenu&gt;
                  &lt;MenuItem Header="Ottieni informazioni" Click="GetInfo" /&gt;
                  &lt;MenuItem Header="Metti in pausa" Click="PauseTransfer" /&gt;
                  &lt;MenuItem Header="Riprendi trasferimento" Click="ResumeTransfer" /&gt;
                  &lt;MenuItem Header="Annulla trasferimento" Click="StopTransfer" /&gt;
              &lt;/ContextMenu&gt;
          &lt;/ListBox.ContextMenu&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;ProgressBar Height="20" Minimum="0" Maximum="100" Name="gasparino_il_carbonaro"
                               Value="{Binding PbStatus}" Width="177" /&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/luKG3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/luKG3.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/JLNra.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JLNra.png" alt="enter image description here"></a></p>
  
  <p>I tried also with (on the ProgressBar template):</p>
  
  <ul>
  <li>HorizontalAlignment="Stretch"</li>
  <li>HorizontalContentAlignment="Stretch"</li>
  </ul>
  
  <p>but with the same following result:</p>
  
  <p><a href="https://i.stack.imgur.com/XkNYc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XkNYc.png" alt="enter image description here"></a></p>
  
  <p>Note that the progress bar item results correctly stretched, but the bar (grey and gree visible part) results compressed (see red arrow).</p>