I have a class, MyAttachedEventClassAquarium
that defines a custom attached as taken from the MSDN documentation. I have a Window
that uses EventTrigger
in XAML to hook the event to be handled on the Window
's viewmodel. The viewmodel is declared as a local resource.
<Window.Resources>
<local:WinVM x:Key="myWinVM" />
</Window.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="NeedsCleaning" SourceName="MyAttachedEventClassAquarium">
<ei:CallMethodAction MethodName="MyCustomEventWasRaised" TargetObject="{StaticResource myWinVM}" />
</i:EventTrigger>
</i:Interaction.Triggers>
I use the window's own RaiseEvent to raise the attached event from a button press handler:
private void button1_Click(object sender, RoutedEventArgs e)
{
((Window1)((Grid)((Button)sender).Parent).Parent).RaiseEvent(new RoutedEventArgs(MyAttachedEventClassAquarium.NeedsCleaningEvent));
}
Why won't my handler be called?
Thanks in advance.
B.