tags:

views:

66

answers:

2

Why doesnt WPF border control have a mousedoubleclick event? I have a ItemsControl with some layout stuff in it for a DataTemplate. I want to handle the double click event to pop up a details dialog, but the border, my layout container, doesn't appear to expose the event.

Any suggestions on how to either get at the double click event, or rework the xaml to make it possible?

+1  A: 

Update: Sorry mistake - late hour

get your mouse button down event and count clicks

 //  e.Handled = true;  whether u need routing or not

 if (e.ClickCount > 1)
 {
    // here comes double click and more :)
 }
lukas
Stackpanel doesnt have a double click event either. what are you suggesting I do with it?
Mr Bell
sry i updated the post
lukas
A: 

MouseDoubleClick is declared on Control so you just need an instance of some Control in your ItemTemplate. The simplest thing to do is use the base Control class which doesn't have any other behavior and just give it a customized template with what's in your ItemTemplate now.

<ItemsControl>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Control MouseDoubleClick="Control_MouseDoubleClick">
                <Control.Template>
                    <ControlTemplate>
                        <Border>
                            <!--Other ItemTemplate stuff-->
                        </Border>
                    </ControlTemplate>
                </Control.Template>
            </Control>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>
John Bowen