我有一个 ListView IsGroupedSource 在它的 CollectionViewSource 中设置为 true。我试图在单击组标题时切换组的可见性。
<CollectionViewSource
x:Name="FiltersViewSource"
Source="{Binding Filters}"
IsSourceGrouped="true"
ItemsPath="AttributeValues"
/>
<ListView
x:Name="filtersListView"
AutomationProperties.AutomationId="ItemListView"
AutomationProperties.Name="Grouped Items"
Grid.Row="1"
Margin="0,-10,0,0"
Padding="30"
ItemsSource="{Binding Source={StaticResource FiltersViewSource}}"
SelectionMode="None"
IsSwipeEnabled="false"
IsItemClickEnabled="True"
ItemClick="ItemView_ItemClick">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="7,7,0,0">
<Button AutomationProperties.Name="Group Title"
Click="Header_Click"
Style="{StaticResource TextPrimaryButtonStyle}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Foreground="White" FontSize="35" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
<TextBlock Text="{StaticResource ChevronGlyph}" Foreground="White" HorizontalAlignment="Right" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
</StackPanel>
</Button>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,0,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemTemplate>
<DataTemplate >
<StackPanel Visibility="{Binding Visibility}" Orientation="Horizontal">
<CheckBox Margin="0,0,20,0"/>
<TextBlock Text="{Binding Name}" Style="{StaticResource ItemTextStyle}" Foreground="White" FontSize="20" MaxHeight="40"/>
<TextBlock Text="(40)" Style="{StaticResource ItemTextStyle}" Foreground="White" FontSize="25" MaxHeight="40"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
基本上我正在尝试创建一个手风琴样式列表。我尝试添加。
<VariableSizedWrapGrid Visibility="{Binding Visibility}" Orientation="Vertical" Margin="0,0,0,0"/>
可见性是基础组对象中可见性类型的属性。
但它不起作用。
有没有办法做到这一点?