单击其内容时如何关闭以下弹出窗口?
<Button Name="myButton" Content="Hover to open" />
<Popup PlacementTarget="{Binding ElementName=myButton}" Placement="Bottom">
<Popup.Resources>
<DataConversion:BooleanOrConverter x:Key="booleanOrConverter" />
</Popup.Resources>
<Popup.IsOpen>
<MultiBinding Mode="OneWay" Converter="{StaticResource booleanOrConverter}">
<Binding Mode="OneWay" ElementName="myButton" Path="IsMouseOver"/>
<Binding RelativeSource="{RelativeSource Self}" Path="IsMouseOver" />
</MultiBinding>
</Popup.IsOpen>
<!-- some content here -->
</Popup>
我想避免在文件后面的代码中编写代码,并将诸如 IsOpen 属性或 MouseDown 事件之类的视觉和行为事物绑定到 ViewModel。