Lots of times, a developer needs to handle a double click event. This trigger allows a developer to track a double click on any FrameworkElement and respond to that using a command.

  1. Add the following XML namespaces:
  1. Use the following definition. This example will invoke the Edit command of the view model when the item is double clicked):
<ListBox x:Name="listBox" ItemsSource="{Binding PersonCollection}" SelectedItem="{Binding SelectedPerson}">
          <catel:DoubleClickToCommand Command="{Binding ElementName=listBox, Path=DataContext.Edit}" />

        <StackPanel Orientation="Horizontal">
          <Label Content="{Binding FirstName}" />
          <Label Content="{Binding MiddleName}" />
          <Label Content="{Binding LastName}" />

The trigger contains an additional property AutoFixListBoxItemTemplate which is set to true by default to easily allow the addition of a double click event to a ListBox. The item template must contain a grid as a base like shown above.

This behavior also supports a constructor that accepts an Action. This way, an anonymous delegate can be executed when the behavior is created in code


We would like to thank the following contributors:

Want to contribute to the documentation? We have a guide for that!


Have a question about Catel? Use StackOverflow with the Catel tag!