Now that we’ve got a decent understanding of the common binding properties of a Selector control (I hope! Given the following classes (only class signatures; the full sample project including source code is attached to this post): Note the use of “Mode=One Way” in my Items Source bindings.
This indicates to the binding that we’re only going to be updating the binding target (the Combo Box’s Items collection in this case).
When programming with the Combobox and handling its Selection Changed Event, you need to be a bit careful.
These can contain multiple values since the same object is used in cases like multiselect List Boxes or List View controls.
So a code like the following is what you can actually write to get the same effect and without relying on hardcoded index values.
The dropdown can still be seen over the VS window while i am debugging the event handler.
It is only after I exit the handler, will this drop down disappear and the new selection appear in the Combo Box's display area (and the values of Selection Box Item and Text property get updated).
Recently, I received a question from one of my twitter tribemates on using the Combo Box in WPF with objects, and it centered around the difference between the Selected Value, Selected Value Path, and Selected Item properties.
This post will go through the differences, and how they are used, and also do a little review on databinding in WPF.A few weeks ago, a friend convinved me to start looking into WPF, XAML and the MVVM pattern. NET Web Forms & MVC2 applications and core system design/development, I haven’t had any exposure to these new(er) technologies, and I thought it might be fun to see what all of the fuss is about. I am using terms in this post in a way which assumes that you are using the MVVM pattern.Note that the information in this post may also be applied to other controls implementing Items Control. Along the way, I came across a situation where I needed to do some different kinds of binding using Combo Boxes.In this post I’ll just cover what I learned about basic data binding, so here is what I needed to do, without all of the Data Template/Grid View bloat Note that in my case, the View Model which the Combo Box needed to get its items from was the Data Context of the page and the Data Context of the Combo Box was the View Model which I needed to bind values to.Now, all of that aside, let’s go over the more common properties used in Data Binding to a Selector control.This is not news, as it works very similarly in Win Forms.