[英]WPF- How can I stop a popup in a control template from closing when clicked?
The control template is for a custom control. 控件模板用于自定义控件。
I have seen this question: Why does a WPF Popup close when its background area is clicked? 我已经看到了一个问题: 为什么单击WPF弹出窗口的背景区域时会关闭它?
However I could not figure out how to bind a command to an event in the control template. 但是我不知道如何将命令绑定到控件模板中的事件。 I tried this:
我尝试了这个:
<Popup
Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="True"
PopupAnimation="Slide"
>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<GalaSoft_MvvmLight_Command:EventToCommand Command="{TemplateBinding PopupClickedCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Popup>
But the command does not fire. 但是该命令不会触发。
尝试使用PreviewMouseLeftButtonDown事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.