wpf caliburn ComboBox OnSelectionChanged事件异常

use*_*050 1 wpf combobox exception mvvm caliburn

我正在尝试使用Caliburn Micro自学WPF,MVVM.到目前为止一切顺利,但是当我的视图中的一个comboBox更改了它的选择时,我有一个问题试图在我的ViewModel中触发一个事件.

这是我的观点的顶部(在Xaml中):

<Window x:Class="Translator.Views.TranslatorView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:model="clr-namespace:Translator.ViewModels"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance Type=model:TranslatorViewModel}"
    Title="Translator" Height="269.301" Width="1030.263"
    xmlns:cal="http://www.caliburnproject.org">
Run Code Online (Sandbox Code Playgroud)

这是我的ComboBox的Xaml:

<ComboBox Name="StoreCombo" Grid.Column="3" Grid.Row="0" Margin="10" Height="25"     SelectedValue="{Binding Type}" 
cal:Message.Attach="[Event SelectionChanged] = [StoreSelectionChanged]"
cal:Action.Target="{Binding ElementName=StoreCombo, Path=DataContext}">
</ComboBox>
Run Code Online (Sandbox Code Playgroud)

这是我的ViewModel中的事件:

public void StoreSelectionChanged(object sender, SelectionChangedEventArgs args)
{
}
Run Code Online (Sandbox Code Playgroud)

但是,在运行应用程序并更改选择时,我得到此异常:

"WindowsBase.dll中发生了'System.Exception'类型的未处理异常附加信息:找不到方法StoreSelectionChanged的目标.如果存在此异常的处理程序,则可以安全地继续该程序."

我试图谷歌这个,但到目前为止,我无法弄清楚我需要做什么.

任何人都可以帮助我吗?

非常感谢

era*_*zap 6

  <ComboBox Name="StoreCombo" SelectedValue="{Binding Type}" 
         cal:Message.Attach="[Event SelectionChanged] = [StoreSelectionChanged]"
         cal:Action.Target="{Binding ElementName=StoreCombo, Path=DataContext}">
  </ComboBox>
Run Code Online (Sandbox Code Playgroud)

(1):Target已经是它的DataContext,所以只需将这一行全部删除即可.

    cal:Action.Target="{Binding ElementName=StoreCombo, Path=DataContext}"         
Run Code Online (Sandbox Code Playgroud)

(2)Caliburn Cheat Sheet,如果你不需要(Sender,EventArgs)

   cal:Message.Attach="[Event SelectionChanged] = [Action StoreSelectionChanged]"
Run Code Online (Sandbox Code Playgroud)

(2.1)如果你想要eventargs:

   cal:Message.Attach="[Event SelectionChanged] = [Action StoreSelectionChanged($eventArgs)]"
Run Code Online (Sandbox Code Playgroud)

(2.2)如果你想要发件人eventargs

   cal:Message.Attach="[Event SelectionChanged] = [Action StoreSelectionChanged($this,$eventArgs)]" 
Run Code Online (Sandbox Code Playgroud)