我正在尝试ToggleButton在我的CollectionViewGroup中找到一个关联,我的xaml结构如下:
<UserControl.Resources>
<CollectionViewSource Source="{Binding Matches}" x:Key="GroupedItems">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="MatchNation" />
<PropertyGroupDescription PropertyName="MatchLeague" />
</CollectionViewSource.GroupDescriptions>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)
你怎么看我有一个CollectionViewGroup过滤ObservableCollection绑定Matches的Nation和League.
为此,我声明了一个ListView有两个GroupStyle,一个用于过滤Country,另一个用于League,在这段代码中我只添加了第二个GroupStyle(包含ToggleButton):
<ListView ItemsSource="{Binding Source={StaticResource GroupedItems}}">
<!-- this is the second group style -->
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="True" Background="#4F4F4F">
<Expander.Header>
<DockPanel Height="16.5">
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="White" FontSize="11.5" VerticalAlignment="Bottom" />
<ToggleButton Checked="{Binding IsFavourite}" HorizontalAlignment="Right"/>
</DockPanel>
</Expander.Header> …Run Code Online (Sandbox Code Playgroud) 我正在尝试检查我的集合中的所有项目是否都有特定的属性值,假设我有一个名为的属性IsFavourite,我需要检查每个元素的属性是否为真.我试过这个:
var c = listView.Items.Cast<Event>().Where(x => x.MatchNation == nation
&& x.MatchLeague == league && x.IsFavourite == true).Any();
Run Code Online (Sandbox Code Playgroud)
但这只会返回一个具有此属性的项目.