Silverlight combobox selecteditem not updating

Next when ever you assign a new object in the View Model to that Property Selected Object should be saved to that Property and not the private member.The viewmodel Proptery should look like this I was fighting with this issue for a while. To String())); private Key Type _Selected Key = new Key Type(); public Key Type Selected Key #endregion Selected Key I had this problem with a Combo Box displaying a list of colors ( List ).

silverlight combobox selecteditem not updating-6

But here is what I get: The previous Selected Item is still there.

, to which the combo box still appears to hold a reference at this moment – which brings it down to a question of proper coercion.

This will result in only the Loaded event being fired when navigating back to a page you have already visited.

So you will need to ensure that you are setting the Data Context on Initialize (either externally or within the constructor) rather than Load.

It turned out that when I added a check to make sure the proposed value for Key Type was not null, everything worked as expected. So i wrote a class Equality Brush containing a Brush and implementing Equals: It could be the way you are applying the Data Context to the Page.

In WPF, everytime you navigate to a Page everything gets re-initialized, constructor gets called, loaded methods, everything.

Or maybe not – the reason behind this is not entirely clear to me.

What seems to be the issue is that the Selected Value/Selected Item is occurring before the Item source is finished loading.

One possible solution is: Based on the selected item id, recover the object on the itemsource collection and set the selected item property to with it.

Tags: , ,