【发布时间】:2017-07-17 03:34:12
【问题描述】:
我正在尝试以 MVVM 友好的方式从 PropertyGrid 或 Extended WPF Toolkit™ by Xceed 绑定到 PreparePropertyItem 事件:
<UserControl x:Class=(...)
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:mvvm="http://prismlibrary.com/"
(...)
<xctk:PropertyGrid x:Name="PropertyGrid" SelectedObject="{Binding}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreparePropertyItem">
<mvvm:InvokeCommandAction Command="{Binding PreparePropertyCommand}"/> //PRISM's InvokeCommandAction doesn't work
<i:InvokeCommandAction Command="{Binding PreparePropertyCommand}"/> //BLEND's InvokeCommandAction doesn't work either
</i:EventTrigger>
</i:Interaction.Triggers>
</xctk:PropertyGrid>
只有当我点击展开 [ExpandableObject] 时才会调用我的自定义 PreparePropertyCommand
这真的很奇怪,因为如果我只是绑定到事件,它就可以直接工作:
<xctk:PropertyGrid x:Name="PropertyGrid" SelectedObject="{Binding}" PreparePropertyItem="PropertyGrid_PreparePropertyItem">
当然,这会破坏 MVVM 模型,因为 PropertyGrid_PreparePropertyItem 在视图的代码隐藏中进行。
有什么见解吗?谢谢!
【问题讨论】:
标签: wpf mvvm wpftoolkit propertygrid icommand