[英]How to bind a collection to Extended WPF Toolkit's DropdownButton?
I'm trying to create a SIMPLE dropdownlist/combobox with a title/header. 我正在尝试创建带有标题/标题的SIMPLE下拉列表/组合框。 I repeat SIMPLE .
我重复SIMPLE 。 I found this pretty
DropdownButton
in Extended WPF Toolkit here . 我在此处的 Extended WPF Toolkit中找到了这个漂亮的
DropdownButton
。 The problem is.. It does not contain anything like ItemsSource
or DataSource
, so I can't even bind my collection = I can't use MVVM pattern (which doesn't make sense in WPF). 问题是..它不包含
ItemsSource
或DataSource
类的东西,因此我什至无法绑定我的集合=我无法使用MVVM模式(在WPF中没有意义)。 Am I missing something here? 我在这里想念什么吗?
Here's the example of my "goal" using ComboBox
这是我使用
ComboBox
“目标”的示例
<ComboBox Margin="5" ItemsSource="{Binding MyOptions}">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding DisplayName}" IsChecked="{Binding IsChecked, Mode=TwoWay}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
This example is almost perfect, but I can't specify a header in ComboBox with simple Header="Check your options:"
. 这个示例几乎是完美的,但是我无法在ComboBox中使用简单的
Header="Check your options:"
指定标题。
The question is: How can I bind a collection from ViewModel to DropdownButton
control? 问题是:如何将ViewModel的集合绑定到
DropdownButton
控件?
Thanks, 谢谢,
The solution could be: 解决方案可能是:
<wpfTool:DropDownButton Content="Options">
<wpfTool:DropDownButton.DropDownContent>
<ListView Margin="0" ItemsSource="{Binding MyOptions}">
<ListView.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding DisplayName}" IsChecked="{Binding IsChecked, Mode=TwoWay}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</wpfTool:DropDownButton.DropDownContent>
</wpfTool:DropDownButton>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.