Windows 商店 xaml 和 c# 如何创建手风琴样式列表 [英] Windows store xaml and c# how to create accordian style list

查看:16
本文介绍了Windows 商店 xaml 和 c# 如何创建手风琴样式列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ListView IsGroupedSource 在它的 CollectionViewSource 中设置为 true.我试图在单击组标题时切换组可见性.

I have a ListView IsGroupedSource is set to true in it's CollectionViewSource. I'm trying to toggle a groups visibility when it's group header is clicked.

<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>

基本上我正在尝试创建一个手风琴样式列表.我尝试添加.

Basically I'm trying to create an accordion style list. I tried adding.

<VariableSizedWrapGrid Visibility="{Binding Visibility}" Orientation="Vertical" Margin="0,0,0,0"/>

可见性是基础组对象中可见性类型的属性.

Visbility is a property of type Visibility in the underlying group object.

但它不起作用.

有没有办法做到这一点?

Is there anyway to accomplish this?

推荐答案

您可以尝试将标题按钮的 Command 属性绑定到视图模型命令,该命令更改您将绑定到 VariableSizedWrapGrid 的组视图模型 Visibility 属性.

You could try binding the Header Button's Command property to a view model command that changes a group view model Visibility property that you would bind to your VariableSizedWrapGrid.

这篇关于Windows 商店 xaml 和 c# 如何创建手风琴样式列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆