ListView を変更したカスタム コントロールがあります。各項目を幅 128 のアイコンとその下のラベルとして表示する DataTemplate があります。
<DataTemplate x:Key="AeroIconTemplate">
<Grid VerticalAlignment="Top" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image Grid.Row="0" Source="{Binding Image}" Width="128"
MaxHeight="128" Margin="0"/>
<TextBlock Grid.Row="1" Text="{Binding Title}" Foreground="Black"
TextWrapping="WrapWithOverflow" Margin="0"
TextTrimming="CharacterEllipsis" Width="128" MaxHeight="60" />
</Grid>
</DataTemplate>
ここで、IconSize という ListView 自体にプロパティを追加しました。これは、16 から 256 までの整数を取ります。
、Width
、、をこのプロパティにバインドします。したがって、IconSize プロパティが変更されるたびに、テンプレートのサイズが調整されます。ご覧のとおり、現在データ オブジェクト(画像ソースとラベル テキスト) にいくつかのものをバインドしていますが、この場合は ListViewコントロールにバインドしたいと考えています。MaxHeight
Image
Width
TextBlock
どうすればいいですか?
ありがとう!