WPF中的CheckedListBox

WPF中的CheckedListBox,wpf,mvvm,infragistics,checkedlistbox,Wpf,Mvvm,Infragistics,Checkedlistbox,我们正在开发一个使用MVVM体系结构风格WPF的应用程序,并且面临一个问题。 在使用WPF之前,我们使用了WinForms和CheckedListBox。但现在我们无法在WPF中找到这样的控制。 我们也在使用基础设施工具包 请提供任何帮助。任何潜在客户都将是可观的。您可以选择一个列表框,并给它一个带有复选框的模板。 比如: <ListBox ItemsSource="{Binding MyItems}"> <ListBox.ItemTemplate>

我们正在开发一个使用MVVM体系结构风格WPF的应用程序,并且面临一个问题。 在使用WPF之前,我们使用了WinForms和CheckedListBox。但现在我们无法在WPF中找到这样的控制。 我们也在使用基础设施工具包


请提供任何帮助。任何潜在客户都将是可观的。

您可以选择一个列表框,并给它一个带有复选框的模板。 比如:

    <ListBox ItemsSource="{Binding MyItems}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <CheckBox IsChecked="{Binding IsSelected}" Content="{Binding}" />
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
这看起来像这样:


编辑:项目必须具有IsSelected属性,或者必须将其包装在SelectableItem帮助器类中,该类保存原始项目和IsSelected属性。

您可以获取列表框并为其提供一个带有复选框的模板。 比如:

    <ListBox ItemsSource="{Binding MyItems}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <CheckBox IsChecked="{Binding IsSelected}" Content="{Binding}" />
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
这看起来像这样:

编辑:项目必须具有IsSelected属性,或者必须将其包装在SelectableItem帮助器类中,该类保存原始项目和IsSelected属性