views:

220

answers:

1

Is it possible to create a command behavior using Prism's CommandBehaviorBase class for Silverlight's grid? I know that it is only intended for actual controls, so I was wondering if anyone might know if a workaround. I would like to create an attachable mouse over behavior for a grid, that executes a specific command, and ideally would like to use Prism for this approach, just can't seem to use CommandBehaviorBase for a Grid.

Thanks.

+1  A: 

The arguably easier way to achieve this is to use Triggers. Doesn't require you to write any code, all you have to do is this:

<Grid>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseEnter">
            <si:InvokeDataCommand Command="{Binding DoSomethingCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    ...
</Grid>

Here the DoSomethingCommand (defined in a ViewModel) will trigger when MouseEnter event is fired on the Grid.

PL