C# 在“中传递事件参数的简单方法”;windows应用程序";使用MVVMLight
我在使用MVVMLight将参数从事件(View/XAML)传递到viewmodel时遇到问题。如何将事件参数传递给命令?我目前正在使用C# 在“中传递事件参数的简单方法”;windows应用程序";使用MVVMLight,c#,mvvm,windows-8.1,C#,Mvvm,Windows 8.1,我在使用MVVMLight将参数从事件(View/XAML)传递到viewmodel时遇到问题。如何将事件参数传递给命令?我目前正在使用 xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core" xmlns:mvvm="http://www.galasoft.ch/mvvmlight" <Grid>
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:mvvm="http://www.galasoft.ch/mvvmlight"
<Grid>
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Loaded">
<Core:InvokeCommandAction Command="{Binding ICommandLoaded, Mode=OneWay}" CommandParameter="{Binding args}" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Grid/>
如何将senderObject和RoutedEventArgs传递给网格层加载的类?与其将其设置为null,不如将其设置为null
我遇到了这个解决方案
有必要为这样简单的任务创建转换器吗?有没有更好的办法。(注意这是在windowsApp中,没有EventToCommand)
对此也感兴趣。将事件命令从代码移到绑定对象中似乎需要大量的工作
public ICommand ICommandLoaded { get; private set; }
ICommandLayerLoaded = new RelayCommand(() => Grid_Loaded(null, null));
public void Grid_LayerLoaded(object sender, RoutedEventArgs e)
{...}