How not to include a Thumb in ListBoxItem selection

Posted by Elad on Stack Overflow See other posts from Stack Overflow or by Elad
Published on 2010-06-14T13:50:51Z Indexed on 2010/06/14 13:52 UTC
Read the original article Hit count: 303

Filed under:
|
|

I have a collection of items. I am presenting the items in a WPF ListBox using DataTemplate. Part of the DataTemplate is a Thumb which is used for resizing and visually separating between items. The Thumb.Visibility is binded to a property of the item (for example, the last item doesn’t have a visible Thumb).

The problem is that selecting an item in the ListBox selects the Thumb as well, as it is part of the ListBoxItem. The desired behavior is to select only the data without the Thumb.
How is it possible to get this behavior? I don’t want to add items by code the ListBox or to handle the visibility of the Thumb manually. Currently I get all this from the DataTemplate.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf