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开发者_如何学C 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!
Use an ItemsControl
directly for displaying your items, not a ListBox
. The ListBox
add the notion of selection, which you don't need.
精彩评论