我是MVVM的新手,我有一些命令在工作。我的申请工作正常。突然间,我有一个疯狂的xaml异常,我试图解决看看StackOverflow上已有的答案。我无法做到。如果我删除interaction.triggers标签,窗口打开正常,否则我有标题中提到的错误。请提供您的意见。谢谢。
<Window x:Class="Test.View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:y="clr-namespace:Test.Framework.Converter"
xmlns:me="clr-namespace:Test"
xmlns:view="clr-namespace:Test.View"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
xmlns:vm="clr-namespace:Test.ViewModel"
DataContext="{Binding Main, Source={StaticResource Locator}}"
Title="Testing Windows" Height="367" Width="620" Icon="/Test;component/Resources/AppIcon.ico" WindowStartupLocation="CenterScreen">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Initialized">
<cmd:EventToCommand Command="{Binding StartInitializingCmd, Mode=OneWay}" />
</i:EventTrigger>
<i:EventTrigger EventName="Loaded">
<cmd:EventToCommand Command="{Binding LoadFeatureListCmd, Mode=OneWay}" />
</i:EventTrigger>
<i:EventTrigger EventName="Closed">
<cmd:EventToCommand Command="{Binding ClosedCmd, Mode=OneWay}" />
</i:EventTrigger>
<i:EventTrigger EventName="Closing">
<cmd:EventToCommand Command="{Binding ClosingCmd, Mode=OneWay}" />
</i:EventTrigger>
<i:EventTrigger EventName="KeyUp">
<cmd:EventToCommand Command="{Binding WindowKeyUpCmd, Mode=OneWay}" />
</i:EventTrigger>
</i:Interaction.Triggers>
MainViewModel.cs
public MainViewModel()
{
StartInitializingCmd = new RelayCommand(() => StartInitializing(), () => true);
fl = new ObservableCollection<Feature>();
fl.CollectionChanged += new NotifyCollectionChangedEventHandler(fl_CollectionChanged);
WindowKeyUpCmd = new KeyBoardCommand(new Action<object, KeyEventArgs>(Window_KeyUp));
ClosedCmd = new RelayCommand(() => Closed(), () => true);
ClosingCmd = new RelayCommand(() => Closing(), () => true);
LoadFeatureListCmd = new RelayCommand(() => StartLoading(), () => true);
}