如何将 collection 绑定到 Extended WPF Toolkit 的 DropdownButton?
How to bind a collection to Extended WPF Toolkit's DropdownButton?
我正在尝试创建一个带有 title/header 的简单 dropdownlist/combobox。我重复 SIMPLE。我在 Extended WPF Toolkit here 中发现了这个漂亮的 DropdownButton
。问题是..它不包含 ItemsSource
或 DataSource
之类的东西,所以我什至不能绑定我的 collection = 我不能使用 MVVM 模式(这不在 WPF 中有意义)。我在这里遗漏了什么吗?
这是我的 "goal" 使用 ComboBox
的示例
<ComboBox Margin="5" ItemsSource="{Binding MyOptions}">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding DisplayName}" IsChecked="{Binding IsChecked, Mode=TwoWay}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
这个例子几乎是完美的,但是我不能用简单的Header="Check your options:"
在ComboBox中指定一个header。
问题是:如何将 collection 从 ViewModel 绑定到 DropdownButton
控件?
谢谢,
解决方案可能是:
<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>
我正在尝试创建一个带有 title/header 的简单 dropdownlist/combobox。我重复 SIMPLE。我在 Extended WPF Toolkit here 中发现了这个漂亮的 DropdownButton
。问题是..它不包含 ItemsSource
或 DataSource
之类的东西,所以我什至不能绑定我的 collection = 我不能使用 MVVM 模式(这不在 WPF 中有意义)。我在这里遗漏了什么吗?
这是我的 "goal" 使用 ComboBox
<ComboBox Margin="5" ItemsSource="{Binding MyOptions}">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding DisplayName}" IsChecked="{Binding IsChecked, Mode=TwoWay}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
这个例子几乎是完美的,但是我不能用简单的Header="Check your options:"
在ComboBox中指定一个header。
问题是:如何将 collection 从 ViewModel 绑定到 DropdownButton
控件?
谢谢,
解决方案可能是:
<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>