Silverlight 4 绑定所选项目文本框的(多个)属性
我有一个编辑器,用户可以从 SL4 中的列表框中选择照片,然后在列表旁边的面板中编辑标题、描述、标签等值。文本框具有 Binding
是列表框的 SelectedItem
的相应属性的 XAML,并且效果很好。但是,我希望能够同时选择多张照片,并为每张照片设置标签。我不知道问题的确切名称,但我试图解释一下,这是任何软件中非常基本的功能,选择多个项目并编辑属性,并且将为所有项目进行编辑。如果属性不同,文本框将显示(多个值)
,如果我不触摸该字段,则这些字段不会发生任何变化。这在 XAML 中可能吗?我非常确定,在 SL 版本 4 发布之前,微软人员会想到一个巧妙的解决方案来解决这个多重选择问题。如果是,如何(请尽可能使用基于 XAML 和 Binding 的声明,否则一切都很容易搞砸)。如果没有直接的方法,那么最干净/最佳的做法是什么?
I have an editor where the user selects a photo from a listbox in SL4, and edits the values like title, description, tags in a panel next to the list. The textboxes have Binding
is XAML to the listbox's SelectedItem
's appropriate properties, and it works nice. However, I want to be able to select multiple photos at the same time, and say, set tags of each. I don't know the exact name of the problem but I tried to explain, it is a very basic functionally in any software, select multiple items and edit a property, and it will be edited for all of them. If the properties are different, the textbox would display (multiple values)
and if I don't touch the field, nothing happens to those fields. Is this possible in XAML? I'm pretty sure up until SL version 4 is released, Microsoft guys would have thought a clever solution to this multiple-selection problem. If yes, how (please, XAML and Binding based declarative as possible or everything easily gets messed up). If there is no starightforward way, what is the cleanest/best practice of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
ListBox.SelectedItems
来枚举和更改所选列表中每个项目的属性。ListBox
应将SelectionMode 设置为 Multiple
。这不是将多个项目属性绑定到文本框的正确方法,因为我们不知道当这些项目具有不同的值时要显示什么,&最好将 ListBox 及其所有属性绑定到集合及其属性
You can use
ListBox.SelectedItems
to enumerate and change the property of each item in the selected list. TheListBox
should haveSelectionMode as Multiple
.Its not a proper way to bind multiple items properties to a textbox, as we don't know what to show when these items have different values, & its better to have ListBox, and all its properties binding to a collection and its properties