Listpicker 多选和 DisplayMemberPath [英] Listpicker Multiple selection and DisplayMemberPath

查看:27
本文介绍了Listpicker 多选和 DisplayMemberPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 ItemsSource 属性绑定到列表选择器的自定义实体集合.我还将选择模式设置为 Multiple,因此我在 FullMode 选择器中为每个项目设置了一个复选框.这个挑选工作,很好,我可以轻松访问通过代码挑选的所有对象.我遇到的问题是 DisplayMemberPath.我想显示比所选对象的命名空间更友好的东西.可能是所选项目的计数,或所选值的逗号分隔列表.

I have a collection of my custom entity that is bound to the listpicker using the ItemsSource property. I also have selection mode set to Multiple so I have a checkbox with each item in the FullMode picker. This picking works, fine, and I can easily access all objects that were picked thru code. What I'm having troubles with is the DisplayMemberPath. I want to display something more friendly than the namespace of the object that is selected. Perhaps a count of selected items, or a comma separated list of the values selected.

不幸的是,当我设置 SelectionMode="Multiple" 时,AccountId"不起作用.单人模式没问题.有什么想法吗?

Unfortunately, 'AccountId' doesn't work when I set the SelectionMode="Multiple". Single mode is fine. Any ideas?

<toolkit:ListPicker 
    x:Name="accountlistpicker"
    Grid.Row="0" Header="accounts" 
    SelectionMode="Multiple"
    DisplayMemberPath="AccountId"
    ItemsSource="{Binding AllAccounts}" 
    FullModeItemTemplate="{StaticResource AccountsListPickerFullItemTemplate}" />

推荐答案

您需要为 SummaryForSelectedItemsDelegate 分配函数,该函数将处理摘要字符串的外观.

You need to assign function to SummaryForSelectedItemsDelegate that will process how summary string will looks like.

查看这个了解更多

这篇关于Listpicker 多选和 DisplayMemberPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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