I am trying to do two things with a ListBox in Silverlight. However, I cannot seem to figure them out.
- I need to change the color of a selected item to yellow, instead of the default blue.
- I set the selected items pr开发者_如何学Googrammatically. Each item is a CheckBox. How do I allow the user to check or uncheck the CheckBox, but keep the item in the ListBox selected?
Thank you!
1) To change the visual structure and visual behavior of a ListBoxItem, copy and modify its default style and template. Use Expression Blend to export the default style. This topic is discussed here(https://stackoverflow.com/questions/1368070/silverlight-listbox-item-style).
2) When I put a CheckBox control on the DataTemplate of a ListBox.ItemTemplate, I am able to check and uncheck the control by clicking the checkbox itself or its associated text without effecting the selection of the ListBoxItem. I am not sure if this is what you are asking. The demensions of your DataTemplate may make this easier or more difficult for the user.
精彩评论