小编Unc*_*ned的帖子

无法在CollectionViewGroup中找到ToggleButton

我正在尝试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绑定MatchesNationLeague.

为此,我声明了一个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)

c# wpf xaml

8
推荐指数
1
解决办法
212
查看次数

如何检查集合中的所有项目是否都具有特定的属性值?

我正在尝试检查我的集合中的所有项目是否都有特定的属性值,假设我有一个名为的属性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)

但这只会返回一个具有此属性的项目.

c# linq

-1
推荐指数
1
解决办法
97
查看次数

标签 统计

c# ×2

linq ×1

wpf ×1

xaml ×1