简体   繁体   中英

How to bind a collection to Extended WPF Toolkit's DropdownButton?

I'm trying to create a SIMPLE dropdownlist/combobox with a title/header. I repeat SIMPLE . I found this pretty DropdownButton in Extended WPF Toolkit here . 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). Am I missing something here?

Here's the example of my "goal" using 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:" .

The question is: How can I bind a collection from ViewModel to DropdownButton control?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM