【问题标题】:Silverlight filtering data with checkboxes like pivotviewer?Silverlight 使用诸如 pivotviewer 之类的复选框过滤数据?
【发布时间】:2011-03-15 16:20:57
【问题描述】:

我正在 Silverlight 中构建一个内部文件门户样式的应用程序,

我需要能够使用诸如 pivotviewer 中的复选框按类别过滤文件:

要使用 ItemsControl 显示类别,并且目前正在使用一种 hacky 解决方法来存储类别 id.. 因此可以在检查或取消检查时适当地添加和删除文件:

                    <ItemsControl x:Name="categoryList" ItemsSource="{Binding}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="2">
                                <CheckBox Checked="categoryIncluded" Unchecked="categoryExcluded" Content="{Binding ID}">
                                    <CheckBox.ContentTemplate>
                                        <DataTemplate>
                                            <!-- This is a hack, content is being used to store the id of the category -->
                                        </DataTemplate>
                                    </CheckBox.ContentTemplate>
                                </CheckBox>
                                <TextBlock Foreground="#FFC2BDBD" Text="{Binding Name}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

这似乎是一次大规模的黑客攻击,

这通常在 Silverlight 中是如何完成的?

(顺便说一下,我正在使用 RIA 数据服务)

【问题讨论】:

    标签: silverlight filtering ria


    【解决方案1】:

    为了避免这种黑客攻击,您可以创建包含 chekbox + 其他数据和 id 属性的自定义控件

    【讨论】:

    • 好建议.. 只是想知道是否已经有办法做到这一点?
    • 您可以使用您的视图模型绑定 IsCheked 属性并在此更改时通知过滤器,因为您在您的视图模型中执行此操作,所以您已经拥有 id 值
    • 很酷,谢谢.. 我最终将复选框子类化并添加了字段:)
    猜你喜欢
    • 2013-06-06
    • 2019-01-04
    • 2021-11-21
    • 2021-06-19
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 2019-12-21
    • 2020-06-10
    相关资源
    最近更新 更多