【发布时间】:2016-03-18 09:15:36
【问题描述】:
我正在使用IsOpen 打开弹出窗口,该IsOpen 绑定到一些难以到达 附加属性。我想要的只是以某种方式将 IsOpen 值传递给 ViewModel。
尝试为此使用 setter:
<Popup StaysOpen="False"
IsOpen="{Binding Path=(local:ListViewBehavior.IsColumnHeaderClicked), RelativeSource={RelativeSource FindAncestor, AncestorType=GridViewColumnHeader}}">
<Popup.Style>
<Style TargetType="Popup">
<Style.Triggers>
<Trigger Property="IsOpen" Value="True">
<!-- this is not possible -->
<Setter Property="{Binding IsPopupOpened ...}" Value="True" />
</Trigger>
</Style.Triggers>
</Style>
</Popup.Style>
</Popup>
给予:
不能在“Setter”类型的“Property”属性上设置“Binding”。只能在 DependencyObject 的 DependencyProperty 上设置“绑定”。
有没有办法将IsOpen 值(已绑定到视图中的其他内容)传递给 ViewModel?
【问题讨论】:
-
<Style TargetType="Popup"><Setter Property="IsOpen" Value="{Binding VMProperty}"></Style>怎么样 -
他已经绑定到 IsOpen 属性...
-
@FrerkMorrin 哇,抱歉。我需要更多的睡眠。