views:

249

answers:

1

Hello,

I am trying to do two things with a ListBox in Silverlight. However, I cannot seem to figure them out.

  1. I need to change the color of a selected item to yellow, instead of the default blue.
  2. I set the selected items programmatically. 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!

A: 

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(http://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.

DaveB