WPF - Listbox bound to collection acts as one item
Posted
by
user553765
on Stack Overflow
See other posts from Stack Overflow
or by user553765
Published on 2011-01-07T10:41:51Z
Indexed on
2011/01/07
10:54 UTC
Read the original article
Hit count: 274
Hi,
I have a listbox with the ItemsControl binding the ItemsSource to a readonly collection of strings.
The ItemTemplate then declares the DataTemplate as a checkbox where its content is that of the name of the particular item in the collection and IsChecked bound to a property to determine whether or not the item is selected (it's just a listbox of checkboxes)
This works fine with one exception - MouseOver the ListBox and it acts as if the collection of Strings is a single item; the whole box acts as if selected. This wouldn't be as much of a problem were it not for this also affecting the scrollbars where they won't get enabled - presumably because it considers the one item as being visible on the screen even though it in actual facts is x+ with only x-y showing on the screen.
How do I get the listbox to act as if each individual string is its own item. I assume it acts this way because I declared a datatemplate in order to get a listbox of checkboxes??
Any help would be much appreciated!
© Stack Overflow or respective owner