我試圖從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