LongListSelector ItemTemplate没有增长

时间:2015-02-12 20:25:09

标签: c# xaml windows-phone-8

我有一个只有两个文本块的itemtemplate但是当一个文本块由于自动换行而增长时,itemtemplate网格不会增长。 我怎样才能做到这一点 ?谢谢你的帮助!

    <DataTemplate x:Key="ArtistTemplate">
        <Grid Height="60" Width="436">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" MinHeight="34" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <TextBlock TextWrapping="Wrap" Text="{Binding Name}" Margin="10,0" Foreground="White" FontSize="26" FontWeight="Bold" Height="34" VerticalAlignment="Top"/>
            <TextBlock TextWrapping="Wrap" Text="{Binding NbAlbum, Converter={StaticResource Converters_IntToStringWithNbAlbum}}" Margin="10,0,10,-21" Foreground="White" FontSize="12" Height="16" VerticalAlignment="Bottom" Grid.Row="1"/>
        </Grid>
    </DataTemplate>

1 个答案:

答案 0 :(得分:1)

将网格高度设置为&#34;自动&#34;。

 <Grid Height="Auto" Width="436">
<Grid.RowDefinitions>
            <RowDefinition Height="auto" MinHeight="34" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <TextBlock TextWrapping="Wrap" Text="{Binding Name}" Margin="10,0" Foreground="White" FontSize="26" FontWeight="Bold" Height="34" VerticalAlignment="Top"/>
        <TextBlock TextWrapping="Wrap" Text="{Binding NbAlbum, Converter={StaticResource Converters_IntToStringWithNbAlbum}}" Margin="10,0,10,-21" Foreground="White" FontSize="12" Height="16" VerticalAlignment="Bottom" Grid.Row="1"/>
    </Grid>