How do I implement a "mouse double click" for a ListBox?

bhs67 96 Reputation points

This xaml code attempts to implement a "mouse double click" for a ListBox "list of cities". xaml

<ListBox x:Name="gLBxCities" Margin="10,0,10,10" Foreground="#0000FF" >



The Compiler -> The member "Handler" is not recognized or is not accessible. I'm not sure of where Handler should be placed?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,665 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,193 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 111.7K Reputation points

    This approach seems to work:

    <ListBox x:Name="gLBxCities" . . .>
            <Style TargetType="ListBoxItem">
                <EventSetter Event="MouseDoubleClick" Handler="MyHandler"/>
    private void MyHandler( object sender, MouseButtonEventArgs e )
    0 comments No comments

  2. Hui Liu-MSFT 37,946 Reputation points Microsoft Vendor

    Hi,@bhs67 . Welcome to Microsoft Q&A.
    To handle a "mouse double click" event in a WPF ListBox, you could use the MouseDoubleClick event and define a corresponding event handler in your code-behind (.xaml.cs) file. Here's an example:

    <ListBox x:Name="gLBxCities" Margin="10,0,10,10" Foreground="#0000FF" MouseDoubleClick="gLBxCities_MouseDoubleClick" >
        <ListBoxItem >q</ListBoxItem>
        <ListBoxItem >s</ListBoxItem>
        <ListBoxItem >4</ListBoxItem>


      private void gLBxCities_MouseDoubleClick(object sender, MouseButtonEventArgs e)

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.