Calling a method from a combo box selection?


Active member
Mar 23, 2014
Programming Experience
I have a project with a ComboBox which lists each day of the week. The user should be able to select a day of the week from the combobox drop down to make 'stuff happen'.

In the code behind I have a method which accepts a string overload for the day of week


I know how do do this using events .. "the winforms way", but I would like to do it properly , "the wpf way" using databinding.

My question then (I think!), is how can I create a data binding which will call a method in the model after making a change in the view?

Is it even possible to do this directly or does it have to be approached differently?
That turned out to be a little easier than expected. Couldn't find anything particularly useful from extensive Google searching but a bit of experimentation yielded the desired result.

Was able to get the desired result in 3 steps.

1. Put method call beneath OnpropertyChanged for SelectedValue

2. Set SelectedValuePath="Content" to get the actual value rather than the full path

3. Set Bindingmode to two way.

The only issue I have now is that the combobox defaults to a blank/empty/non selected state. Does anyone know how I can add some default 'Please Select' text or specify an index to start at upon loading?
Top Bottom