未找到 WPF MVVM EventToCommand.cs
WPF MVVM EventToCommand.cs not found
我正在为我的一个应用程序使用 WPF MVVM Light。我在调试代码时发现错误是 "EventToCommand.cs not found" on Window Loaded Command.
我的代码是:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing" >
<command:EventToCommand Command="{Binding WindowCloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="Loaded" >
<command:EventToCommand Command="{Binding WindowLoadedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window},Mode=FindAncestor}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
在视图模型中:
public ICommand WindowLoadedCommand
{
get { return _windowLoadedCommand ?? (_windowLoadedCommand = new RelayCommand<MetroWindow>(OnWindowLoaded)); }
}
public void OnWindowLoaded(MetroWindow window)
{
}
请帮我找出解决这个问题的方法。
Use following code it might be work because in my case it's working.
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding WindowLoadedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
ViewModel.cs,
public ICommand WindowLoadedCommand
{
get { return new RelayCommand<object>(WindowLoadedCommandExecute); }
}
public void WindowLoadedCommandExecute(object obj)
{
}
我有 same problem,这最终为我解决了这个问题:
xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap" >
<Command:EventToCommand Command="{Binding Path=MyVM.MyCommand, Source={StaticResource Locator}}"
PassEventArgsToCommand="False"
CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
我正在为我的一个应用程序使用 WPF MVVM Light。我在调试代码时发现错误是 "EventToCommand.cs not found" on Window Loaded Command.
我的代码是:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:command="http://www.galasoft.ch/mvvmlight"
<i:Interaction.Triggers>
<i:EventTrigger EventName="Closing" >
<command:EventToCommand Command="{Binding WindowCloseCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
<i:EventTrigger EventName="Loaded" >
<command:EventToCommand Command="{Binding WindowLoadedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window},Mode=FindAncestor}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
在视图模型中:
public ICommand WindowLoadedCommand
{
get { return _windowLoadedCommand ?? (_windowLoadedCommand = new RelayCommand<MetroWindow>(OnWindowLoaded)); }
}
public void OnWindowLoaded(MetroWindow window)
{
}
请帮我找出解决这个问题的方法。
Use following code it might be work because in my case it's working.
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding WindowLoadedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
ViewModel.cs,
public ICommand WindowLoadedCommand
{
get { return new RelayCommand<object>(WindowLoadedCommandExecute); }
}
public void WindowLoadedCommandExecute(object obj)
{
}
我有 same problem,这最终为我解决了这个问题:
xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap" >
<Command:EventToCommand Command="{Binding Path=MyVM.MyCommand, Source={StaticResource Locator}}"
PassEventArgsToCommand="False"
CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>