Best friend chatroom no sign ups - Silverlight combobox selectedvalue not updating

In essence, if you have a Combo Box with its Selected Value bound to a property and set that property to null, the Combo Box throws out your binding. No view models or anything fancy, just one user control: This code sets up a Combo Box with the appropriate settings, a Text Block bound to the same property as the Combo Box’s Selected Value binding, and a button to clear our selection (by setting said property to null). For posterity, here is an incredibly simple reproduction scenario.

silverlight combobox selectedvalue not updating-43

Silverlight combobox selectedvalue not updating

When the application is run and the Combo Box selection is changed, the Text Block’s text updates as expected.

When you click Clear selection, both the Combo Box and Text Block clear: Finally, making another selection in the Combo Box demonstrates the issue: What’s going on here?

This is not a new topic, as you can easily see if you'll look here, here, here or on the official msdn page here.

(Do note that at the the official msdn (at the time of writing this), 0 out of 4 rated it helpful) .

When the binding occurs, it is trying to see if the objects match so make sure you are properly implementing your equality checking. I implemented IEquatable on My Object and match the fields and return true. If I add a Textbox bound to the Property it is showing the correct information upon return to the page.

In this case, the selecteditem bind doesn't work, because the hash id of the objects are different.The object is returning the correct object via the get in the property though.I'm not sure if this is just an issue with the way the Combo Box and MVVM pattern works. I have had similar issues and it was solved by making sure I was implementing IEquatable properly.: This will return the currently selected item in thelist/combobox/container . I wanted to keep this as simple and short as can be, while delivering enough punch to be interesting.This is an Object as you can see (since my list holds objects). I use a simple Xaml file with some Code Behind, and it all clocks in at some 200 lines of code (including spaces and some comments).Please check my last scenario in the following list to get a brief idea about the properties.

680 Comments

  1. Pottermore makes you experience the Harry Potter adventure online.

  2. In fact, I receive emails every day from people saying, “I have a horrible financial problem. ” and 30% of the time, it’s directly related to their mortgages.

Comments are closed.