Message.Attach on a custom event

Topics: Actions & Coroutines
Aug 19, 2013 at 7:53 AM
Hi,

I've made a user control that has it's own Click Event. The control sits inside an items control
I can hook to this event in xaml/code behind as normal fine.

e.g.
    <ItemsControl Grid.Column="1" Background="{x:Null}" Grid.Row="1" MaxHeight="40" VerticalAlignment="Top"
             BorderBrush="{x:Null}" 
             Style="{DynamicResource NoticationsItemsControlStyle}" 
             IsTabStop="False"
             ItemsSource="{Binding Notification, Mode=TwoWay}"
             ScrollViewer.HorizontalScrollBarVisibility="Hidden">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Controls:NotificationItem Model="{Binding .}"  Margin="0,0,0,10" Click="NotificationItem_Click"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
Using the message Attach syntax however doesn't seem to work as below:
    <ItemsControl Grid.Column="1" Background="{x:Null}" Grid.Row="1" MaxHeight="40" VerticalAlignment="Top"
             BorderBrush="{x:Null}" 
             Style="{DynamicResource NoticationsItemsControlStyle}" 
             IsTabStop="False"
             ItemsSource="{Binding Notification, Mode=TwoWay}"
             ScrollViewer.HorizontalScrollBarVisibility="Hidden">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Controls:NotificationItem Model="{Binding .}"  Margin="0,0,0,10" cal:Message.Attach="[Event Click] = [Action Test]"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

I'm having trouble with the Message.Attach - it doesn't seem to hook up to test method. So when they click my handler is null and never fires and never calls the test method.

I've tried setting the Action.TargetWithoutContext property to the context of the itemscontrol, the grid above it and the user control itself.
Jan 6, 2014 at 9:26 AM
Hi,
Did you make any progress on this?
I have almost the identical problem.
Jan 9, 2014 at 1:03 PM
Since CM relies on the System.Windows.Interactivity.EventTrigger, it shares some limitations with it. In particular, the event needs to be either a EventHandler<T> or EventHandler, if I remember correctly.

Are you positive that this requirement is fullified?