【发布时间】:2011-03-11 12:47:06
【问题描述】:
我在一个网格中有两个控件,一个 Ellipse 和一个 Popup。这个想法是只有当视图模型中的 IsDirty 属性为 true 时才会显示这两个控件;如果是这样,如果相同的视图模型 IsValid,Ellipse 为绿色,否则为红色,而如果用户将鼠标悬停在弹出窗口上,则 Popup 显示消息。
Popup 的内容和绑定是正确的,所以我想知道我是否应该能够通过使用它自己的样式的触发器来控制它是否 IsOpen,如下面的代码所示。
干杯,
浆果
<Popup x:Name="dirtyPopup" AllowsTransparency="True" >
<Popup.Style>
<Style TargetType="Popup">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsOpen" Value="{Binding IsDirty}"/>
</Trigger>
</Style.Triggers>
</Style>
</Popup.Style>
<Grid content goes here />
</Popup>
【问题讨论】:
标签: wpf popup visibility