我试图从Extended WPF Toolkit™ by Xceed
PropertyGrid
在MVVM友好的方式绑定到PreparePropertyItem
事件:WpfToolkit PropertyGrid的
<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>
我定制PreparePropertyCommand当PropertyGrid中被加载或显示没有被调用,只有当我点击展开的[ExpandableObject]
这是很奇怪的,因为它的工作原理直出,如果我只是绑定到事件:
<xctk:PropertyGrid x:Name="PropertyGrid" SelectedObject="{Binding}" PreparePropertyItem="PropertyGrid_PreparePropertyItem">
当然这打破了MVVM模型,因为PropertyGrid_PreparePropertyItem
在视图的代码隐藏之上。
任何见解?谢谢!
很好的答案,谢谢! – IgorMF