locked
Resize progress bar to fit listview column when resized RRS feed

  • Question

  •     <ListView Name="listViewQueue" ItemsSource="{Binding}">
          <ListView.View>
            <GridView>
              <GridViewColumn Width="100" Header="Progress">
                <GridViewColumn.CellTemplate>
                  <DataTemplate>
                    <ProgressBar Name="prgDownload" MinWidth="80" Height="20" Minimum="0" Maximum="100" Value="{Binding Progress}" HorizontalAlignment="Stretch"/>
                  </DataTemplate>
                </GridViewColumn.CellTemplate>
              </GridViewColumn>
    .
    .
    .
    .
    
            </GridView>
          </ListView.View>
        </ListView>
    Hi There,

     

    Im trying to achieve this, can anybody spot something wrong with my styling?

     

    Thanks

     

    Sean

     

     

    Friday, January 21, 2011 4:29 PM

Answers

  • Hi s34n,

    You could use below code snippet to resolve your issue:

      <Style TargetType="{x:Type ListViewItem}">

     

            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>

     

        </Style>

    The property is "HorizontalContentAlignment", and then I think your issue could be resolved.

    On the other hand, noorbakhsh's solution is another way to achieve it.

     

    Best regards,


    Sheldon _Xiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Sheldon _Xiao Monday, January 24, 2011 9:28 AM
    • Marked as answer by Sheldon _Xiao Friday, February 4, 2011 7:46 AM
    Monday, January 24, 2011 8:36 AM

All replies

  • Sean,

    Try wrapping the ProgressBar in A Grid in the DataTemplate. Might help.


    noorbakhsh حميد نوربخش
    Friday, January 21, 2011 5:28 PM
  • Hi s34n,

    You could use below code snippet to resolve your issue:

      <Style TargetType="{x:Type ListViewItem}">

     

            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>

     

        </Style>

    The property is "HorizontalContentAlignment", and then I think your issue could be resolved.

    On the other hand, noorbakhsh's solution is another way to achieve it.

     

    Best regards,


    Sheldon _Xiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Sheldon _Xiao Monday, January 24, 2011 9:28 AM
    • Marked as answer by Sheldon _Xiao Friday, February 4, 2011 7:46 AM
    Monday, January 24, 2011 8:36 AM
  • Hi There,

    Thanks for the responses.

     

    I couldn't get the first suggestion to work, but the second one works perfect.

    Thank you.

     

    Regards,

    Sean

    Monday, January 24, 2011 9:19 AM
  • Hi s34n,

    I think I have resolved your issue, so I am marking your issue as the "Answered", if you have new findings about this issue, please unmark.

     

    Best regards,


    Sheldon _Xiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 31, 2011 2:18 AM
  • Hi, i tried your method but it doesn't stretch my progress bar, i have no idea why! Here some snippet from my code:

    <Window.Resources>
    	<Style TargetType="{x:Type ListViewItem}">
    		<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
    	</Style>
    ...
    </Window.Resources>
    
    <ListView x:Name="downloadListXaml" Height="194" Margin="10,0,10,41" VerticalAlignment="Bottom" ItemContainerStyle="{StaticResource itemstyle}">
        <ListView.View>
            <GridView>
    			<GridViewColumn Width="auto" Header="Progress">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <ProgressBar Name="prgDownload" MinWidth="80" Height="20" Minimum="0" Maximum="1000" Value="{Binding progress}" HorizontalAlignment="Stretch"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>

    any idea?

    Tuesday, December 31, 2013 9:58 AM