<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction CommandParameter="{}" Command="{Binding ChangeViewModelCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>在ViewModel本身中,我定义了一个Dictionary<string, IViewModel>,它包含对应用程序的每个ViewModel的引用。该属性为ApplicationViewModels。通过此命令,是否可以访问特定的Dictionary条目ApplicationViewModels
目标是将一个已经实例化的实例传递给命令。
发布于 2015-10-28 18:21:50
是的,你可以这样做,这很简单:
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction CommandParameter="{Binding ApplicationViewModels[DictKey]}" Command="{Binding ChangeViewModelCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>其中DictKey是您要传递的视图模型的关键。
https://stackoverflow.com/questions/33397400
复制相似问题