desfen
desfen

Reputation: 11

InvokeCommandAction won't work when used in an EventTrigger?

this is my first question on stack-overflow so please be gentle :-)

In one of my WPF windows I have a listbox whose items are templated with the following data template:

<ListBox.ItemTemplate>
<DataTemplate>
    <Grid UseLayoutRounding="True" Width="80">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border
            Grid.Row="0"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
        >

            <Viewbox 
                Height="110"
                Width="50"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
            >
            <Grid Background="#77ffffff" Margin="0">
                <i:Interaction.Triggers>
                    <ei:KeyTrigger Key="Return">
                        <i:InvokeCommandAction 
                            Command="{Binding SelectModelCommand}"
                            CommandParameter="{Binding}"
                        />
                    </ei:KeyTrigger>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <i:InvokeCommandAction 
                            Command="{Binding SelectModelCommand}"
                            CommandParameter="{Binding}"
                        />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <Path Stroke="{DynamicResource FontBrush}"
                    StrokeThickness="100"
                    Data="{Binding DrawingPathString, FallbackValue={x:Static bll:Panel.NoDrawing}}"/>
            </Grid>
            </Viewbox>
        </Border>

        <TextBlock 
            Grid.Row="1"
            FontSize="8"                
            TextWrapping="NoWrap"  
            HorizontalAlignment="Center"
            Text="{Binding Path=BLLPanel.Model,FallbackValue=MODEL}"
        />
        <TextBlock 
            Grid.Row="2"
            FontSize="8"                
            TextWrapping="NoWrap" 
            HorizontalAlignment="Center"
            Text="{Binding Path=BLLPanel.PanelFamily.Description,FallbackValue=FAMILY}"
        />
    </Grid>
</DataTemplate>

Notice the two triggers in the Grid:

Can anyone explain to me why ? Thanks for your time and consideration

Sven

Upvotes: 1

Views: 4234

Answers (1)

Pavlo Glazkov
Pavlo Glazkov

Reputation: 20746

The thing is that there is no MouseDoubleClick event...

But I believe what you are trying to do can be easily achieved using ImputBindings:

<Grid Background="#77ffffff" Margin="0">
            <Grid.InputBindings>
                <MouseBinding Gesture="LeftDoubleClick" Command="{Binding SelectModelCommand}"/>
            </Grid.InputBindings>
    ...
</Grid>

Upvotes: 3

Related Questions