WPF 组合框应该只在箭头上打开 [英] WPF Combobox should only open on arrow

查看:17
本文介绍了WPF 组合框应该只在箭头上打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有机会更改仅当我单击左侧的箭头时才打开的 wpf 组合框?通常您可以单击任意位置将其打开.我不想那样.

Is there a chance to change the wpf combobox that it only opens when I click on the arrow on the left side? Usually you can click anywhere to open it. I dont want that.

谢谢

推荐答案

通常您可以单击任意位置将其打开.我不想那样.

Usually you can click anywhere to open it. I dont want that.

然后您应该为 ToggleButton 创建一个自定义模板.Yan 在 Visual Studio 或 Blend 中的设计模式下右键单击 ComboBox 元素,然后选择编辑模板"->编辑副本".

Then you should create a custom template for the ToggleButton. Yan right-click on the a ComboBox element in design mode in Visual Studio or in Blend and choose Edit Template->Edit a copy.

这会将默认模板复制到您的 XAML 标记中,然后您可以根据需要对其进行编辑.寻找一个 x:Key 为 "ComboBoxToggleButton" 的 Style 并修改它的 ControlTemplate.

This will copy the default template into your XAML markup and you can then edit it as per your requirements. Look for a Style with an x:Key of "ComboBoxToggleButton" and modify the ControlTemplate of this one.

这篇关于WPF 组合框应该只在箭头上打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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