Jordan
Jordan

Reputation: 9901

In the ListBoxItem template, how do I change the visual state of the item based upon IsSelected?

I'm wanting to increase the size of a selected item in a ListBox and show extra controls. I'm not sure how the ListBoxItem template knows whether the item is selected or not. In the past I would wrap all of my items in radio buttons but it is very clunky and didn't utilize the ListBox selection at all. I would really like to have a better way. Ideally, I would like the change to be in a visual state so I can animate the transition.

Thanks.

Upvotes: 1

Views: 1421

Answers (1)

Clemens
Clemens

Reputation: 128013

ListBoxItem already defines the visual states Selected and Unselected. See ListBox Styles and Templates for how the ControlTemplate in ListBoxItem's default style handles these states.

Upvotes: 1

Related Questions