[英]Specific Dictionary Element as CommandParameter
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction CommandParameter="{}" Command="{Binding ChangeViewModelCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
In the ViewModel, itself, I have a Dictionary<string, IViewModel>
defined which contains a reference to every ViewModel
of the application. 在ViewModel本身中,我定义了
Dictionary<string, IViewModel>
,其中包含对应用程序每个ViewModel
的引用。 The property is ApplicationViewModels
. 该属性是
ApplicationViewModels
。 From this command, is it possible to access a specific Dictionary
entry of ApplicationViewModels
? 通过此命令,可以访问
ApplicationViewModels
的特定Dictionary
条目吗?
The goal is to pass an already instantiated instance to the command. 目标是将已经实例化的实例传递给命令。
Yes, you can and it's very simple to do so: 是的,您可以并且这样做非常简单:
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction CommandParameter="{Binding ApplicationViewModels[DictKey]}" Command="{Binding ChangeViewModelCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
Where DictKey is the key of the viewmodel you're trying to pass. DictKey是您要传递的视图模型的键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.