I have a situation with a ListBox control. Inside the item template there is a button. When I click the button I want to selected item of said ListBox to change to the item the button is in. At the moment, I can change the selected item by clicking elsewhere within the item template, but that doesn't work if I select the button. To clarify that last sentence for a commenter, if one clicks in the item template that is not the button, the SelectedItem will change as expected. If you click on the button within the item template, the SelectedItem will not change.
Further information: I am using MVVM and the button has attached to it a command within a view model. Any solution would need to allow this to continue to work.
The ListBox is linked to ItemSource, and the SelectedItem of the ListBox is bound to a property in the view model.
If there's a set way to do this, I've so far been unable to find it.
I am using C# and Visual Studio 2010.
Thanks.