Question

These are all ListViews. They all will contain max 5 items. I want them to fill vertically, so in this case these three items should cover 3/5 of the ListView how can I do that? Of course when the Window is resized the items must change to.

http://s14.directupload.net/images/140423/c5mayx9t.png

<Grid.Resources>
        <Style TargetType="{x:Type ListViewItem}">              
                <Style.Setters>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListViewItem}">                                    
                                <Border BorderBrush="#5076A7" BorderThickness="1" CornerRadius="4">
                                    <Border.Background>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                            <GradientStop Color="#FFFFFF" Offset="0.0"/>
                                            <GradientStop Color="#C0D3EA" Offset="1.0"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <StackPanel TextElement.FontFamily="Segoe UI" TextElement.FontSize="12">
                                        <TextBlock FontWeight="Bold" Padding="3,0,0,0" Text="{Binding Path=Name}"/>
                                        <TextBlock Padding="3,0,0,0" Text="{Binding Path=Age}"/>                                                                                
                                    </StackPanel>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>                       
                </Style.Setters>
            </Style>
    </Grid.Resources>
Was it helpful?

Solution

You can use a UniformGrid:

<ListView>
   <ListView.ItemsPanel>
      <ItemsPanelTemplate>
          <UniformGrid Rows="5" Columns="1" />
      </ItemsPanelTemplate>
   </ListView.ItemsPanel>
</ListView>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top