单击标题时防止 WPF 扩展器扩展 [英] Preventing a WPF Expander from expanding when header is clicked

查看:32
本文介绍了单击标题时防止 WPF 扩展器扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止 WPF Expander 在单击其标题时展开?我希望我的 Expander 仅在单击展开按钮本身时展开或折叠.

How can I prevent a WPF Expander from expanding when its header is clicked? I would like my Expander to expand or collapse only when the expand button itself is clicked.

我想答案与取消冒泡事件有关.如果可能,我想在 XAML 中实现解决方案,同时避免重新模板化整个 Expander.

I imagine the answer has something to do with canceling a bubbled event. If possible I would like to implement the solution in XAML while avoiding retemplating the entire Expander.

推荐答案

标题是创建事件的按钮,因此您需要更改扩展器的模板,将扩展器图标作为按钮.

The header is the button that creates the event, so you need to change the template for your Expander to just have the expander icon as the button.

这是如何更改扩展器.

这篇关于单击标题时防止 WPF 扩展器扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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