実行時にいくつかの条件に基づいてGroupStyles
切り替えるにはどうすればよいですか?ListView
たとえば、GroupStyle
ヘッダー名がnullのアイテムにはデフォルトを使用する必要があり、nullでない場合は、カスタムGroupStyle
テーマを使用しますか?試してみGroupStyleSelector
ましたが、マルチレベルのグループ化で機能するため機能しません。私の場合、レベルのグループ化は1つしかありません。
はいの場合、どのように?
カスタムGroupStyle
:
<Style x:Key="grouping"
TargetType="{x:Type GroupStyle}">
<Setter Property="ContainerStyle">
<Setter.Value>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Margin"
Value="0,0,0,5" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="False"
BorderBrush="#FFA4B97F"
BorderThickness="0,0,0,1">
<Expander.Header>
<DockPanel>
<TextBlock FontWeight="Bold"
Text="{Binding Name}"
Margin="0"
Width="250" />
<TextBlock FontWeight="Bold"
Text="{Binding Path=Items[0].StartTime, StringFormat=T}" />
</DockPanel>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
どうもありがとう。
よろしくお願いいたします。