Saturday, 10 August 2013

Variabile-Sized GridViewItem in GridView

Variabile-Sized GridViewItem in GridView

In a GridView (Windows 8 App), I use the following item template to show
the items :
<DataTemplate x:Key="ProjectTemplate">
<StackPanel>
<Grid Width="500" Background="MidnightBlue">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Name}" Margin="20, 10"
Style="{StaticResource SubheaderTextStyle}"
TextWrapping="Wrap" Foreground="WhiteSmoke"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="20,
10, 10, 10" Background="MidnightBlue">
<TextBlock Text="Last Modified :" Style="{StaticResource
TitleTextStyle}" Foreground="WhiteSmoke"/>
<TextBlock Text="{Binding LastModified}" Margin="5, 0, 0,
0" Style="{StaticResource TitleTextStyle}"
Foreground="WhiteSmoke"/>
</StackPanel>
<TextBlock Grid.Row="2" Text="{Binding VideoPath}" Margin="20,
10, 10, 10" Style="{StaticResource TitleTextStyle}"
TextWrapping="Wrap" Foreground="WhiteSmoke"/>
</Grid>
</StackPanel>
</DataTemplate>
So, mainly, it is a Grid with three rows showing data binded for Name,
LastModified and VideoPath properties of my Project item the GridView
deals with. The items are retrieved correctly, the binding is OK, my
problem is more a matter of... design.
Here's an example :

If you notice, the first two items, seem OK - they have the Name,
LastModified Date and VideoPath shown. The third item, on the other hand,
has a longer Name shown in a TextBlock with TextWrapping=true. Also the
third textblock for the VideoPath has the TextWrapping set.
Is there any way I could enlarge the grid to show the full content? What
modifications I need to make to the template?

No comments:

Post a Comment