: 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).
While your example is good for a very simple Combo Box example, it has some misleading information.
Contrary to popular belief, INotify Property Changed is NOT necessary in either of your examples to get them to work.
In my application, I like the way the view model is structured and the XAML is laid out and I don’t want to change the way things work, so what do I do? There are other workarounds such as subclassing Combo Box, but I’m of the opinion that much of the Silverlight and WPF framework code wasn’t written with subclassing in mind and it can be more of a pain to subclass than it is to attach a behavior of some sort to an existing class.
If my binding is being deleted on a null value, can I re-add it? In addition to this, I personally find it easier to attach a behavior and if the reason for the behavior is ever fixed, I can simply remove the behavior wherever it’s used. So instead of subclassing, I’m going to go with behavior attaching, and this is where the Expression SDK comes in.
Comment its implementation to validate that statement.
They say a picture is worth a 1000 words, so here's a picture: I say a demo is worth a 1000 pictures, so feel free to download the code and play with it yourself.
The issue was that my view model inherited from a base view model which implemented a property changed method.
I had a property changed event in my view model as well because I didn't realize this base view model class had one in there.
I have tried Selected Item, Selected Index, Text and nothing works for me.
Here is my xaml: Here is my Web Service completed method, where I populate the Items Source (which works) and then I try to set the Selected Item (which doesn't update the UI, but my Selected Item raise property event does fire) This problem is driving me absolutely bonkers!