问题描述
我刚刚开始使用WPF,需要一个复选框的特定功能:
I have just started with WPF and need specific feature for a checkbox:
- 我想将一个盒子的形状改为椭圆。
- 更多的应该是颜色变化(绿色=真,红色=假),而不是交叉。
背景:我有不同的传感器,并希望通过这些复选框启用/禁用它们。我也想过使用按钮而不是复选框,但我认为该功能更多的复选框。
The background: I have different sensors and want to enable/disable them via these checkboxes. I also thought about to use buttons instead of checkboxes, but I think the function is more given by the checkboxes.
我希望我的描述是可以理解的。是否可以定义这样的样式模板?
I hope my description is understandable. Is it possible to define such a style- template?
亲切问候
Alex
推荐答案
您需要自定义复选框并创建自定义模板 。
为此,您需要更改 。
You're going to need to customize the Checkbox and create a Custom Template.
For that you need to change the default Checkbox Template.
你想要做的是使用触发器和背景来调整它的样式。注意 CheckMark
属性,您可能希望保留隐藏
What you want to do is play a little bit with the triggers and background to style it like you want. Notice the CheckMark
property, you'll probably want to keep it Hidden
这篇关于WPF复选框样式更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!