On my previous post i showed how you can attach a double-click event to any Silverlight object.
using this method i’ll show you how to attach a double click event to a ListBox item.
the problem here is that we don’t have any object that we can count on.
i edited the ListBoxItem template, the only change i’ve done is to add a transparent rectangle above all.
look for it inside the template – its name is “DummyRectForDoubleClick”.
then on the Loaded event of this rectangle i attach to it the double click event.

April 10, 2009 at 20:51 |
Thanks for the info and source code, your implementation is cleaner then most of the example’s I’ve seen.
April 16, 2009 at 18:25 |
Hi, i have tested this in Silverlight3, but does not work
Have you tried ?
April 17, 2009 at 16:00 |
actually no, haven’t tried this on SL3.
will check…
September 14, 2009 at 10:03 |
This solution does not work on SL3. This error is shown:
{System.IndexOutOfRangeException: Índice fuera de los límites de la matriz.
en System.Windows.Controls.ItemContainerGenerator.RealizedItemBlock.ContainerAt(Int32 index)
en System.Windows.Controls.ItemContainerGenerator.ContainerFromIndex(Int32 index)
en System.Windows.Controls.ListBox.MakeToggleSelection(Int32 index)
en System.Windows.Controls.ListBox.HandleItemSelection(ListBoxItem item, Boolean isMouseSelection)
en System.Windows.Controls.ListBox.OnListBoxItemClicked(ListBoxItem item)
en System.Windows.Controls.ListBoxItem.OnMouseLeftButtonDown(MouseButtonEventArgs e)
en System.Windows.Controls.Control.OnMouseLeftButtonDown(Control ctrl, EventArgs e)
en MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)}