tags:

views:

21

answers:

1

Hello,

I'am just coding some global gesture handlers for a wpf application. For example I am supposed to use right click as a trigger to proceed UI.

<Window.InputBindings>
        <MouseBinding MouseAction="RightClick" Command="NavigationCommands.NextPage"/>
</Window.InputBindings>

But now the problem appears that <ListBox/> consumes all mouse button events. I did some research but didn't found an easy way to make it just be unaware of the right button. Did anybody ever had this problem and found a solution? Thanks in advance.

A: 

You should be able to prevent the ListBox from consuming the mouse clicks using the following:

<ListBox>
        <ListBox.InputBindings>
            <MouseBinding MouseAction="RightClick" Command="ApplicationCommands.NotACommand" />
        </ListBox.InputBindings>
    </ListBox>
Steve Greatrex
Does not work. Right click still enables ListBox.
Matze
How sure are you that your command isn't being executed? In my simple example (below - sorry about the formatting!) my event handler is invoked correctly when I right click on my listbox.<Window.CommandBindings> <CommandBinding Command="NavigationCommands.NextPage" Executed="CommandBinding_Executed" /> </Window.CommandBindings> <Window.InputBindings> <MouseBinding MouseAction="RightClick" Command="NavigationCommands.NextPage" /> </Window.InputBindings> <Grid> <ListBox Background="Red" /> </Grid>
Steve Greatrex