EventSetter and ViewModel

Nov 22, 2010 at 2:12 PM

I am trying to wire up a 3rd party control (Infragistics Datagrid) with my ViewModel. In order to handle the double-click event only on a row, I need to access the PreviewMouseDoubleClick event inside what is called the DataRecordPresenter.

My main question is... how do I handle this to call a method in my ViewModel?

<igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <EventSetter Event="PreviewMouseDoubleClick" Handler="My-VM-Method" /> </Style> </igDP:XamDataGrid.Resources> ...

Normally, I would just use something like this:

cal:Message.Attach="[Event PreviewMouseDoubleClick] = [Action My-VM-Method()]"

But it will not allow me to place that inside the <EventSetter />

Any suggestions?

Nov 22, 2010 at 2:27 PM

Try using a basic style setter like so:


<Style TargetType="{x:Type igDP:DataRecordPresenter}">
    <Setter Property="cal:Message.Attach" Value="[Event PreviewMouseDoubleClick] = [Action My-VM-Method()]" />

Nov 22, 2010 at 2:54 PM

Nice solution. It works. Thanks!