正在寻找一个带有复选框的WPF组合框 [英] Looking for a WPF ComboBox with checkboxes

查看:111
本文介绍了正在寻找一个带有复选框的WPF组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的google技能无法使用。任何人听说过像WPF的控制。我试图让它看起来像这样(winforms截图)。

My google skills fail me. Anyone heard of a control like that for WPF. I am trying to make it look like this (winforms screenshot).

推荐答案

你可以通过设置组合框的DataTemplate自己做。 本文介绍了如何为列表框,但原则是同样。

You can do this yourself by setting the DataTemplate of the combo box. This article shows you how - for a listbox, but the principle is the same.

另一篇文章这里可能更适合你想做什么,简单将项目模板的第一列设置为复选框并将其绑定到业务对象上的布尔。

Another article here is perhaps a better fit for what you are trying to do, simple set the first column of the item template to be a checkbox and bind it to a bool on your business object.

<ComboBox.ItemTemplate>
    <DataTemplate>
        <StackPanel Orientation="Horizontal">
            <CheckBox IsChecked="{Binding IsSelected}"
                       Width="20" />
            <TextBlock Text="{Binding DayOfWeek}"
                       Width="100" />
        </StackPanel>
    </DataTemplate>
</ComboBox.ItemTemplate>

这篇关于正在寻找一个带有复选框的WPF组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆