寻找带有复选框的 WPF ComboBox [英] Looking for a WPF ComboBox with checkboxes

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

问题描述

我的谷歌技能让我失望.任何人都听说过类似 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.

另一篇文章 此处 可能更适合您要执行的操作,只需将项目模板的第一列设置为复选框并将其绑定到业务对象上的 bool.

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 ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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