WpfDatabind5 ( WPF )

Objectives:
Step:1 Create a New project Wpf

WpfDatabind5

Add Class

Add few controls as shown in the illustration below

Step:2 Edit Code in Class1.cs

Step:3 Edit mark up scripts in MainWindow.xaml

Step:4 Edit Code behind

Step:5 Runtime views

a) Using DataContext

Although, setbinding worked, but  comboBox1.SelectedItem.ToString() did not show the selected value, rather displayed the type.

b) Testing the combobox

Note the difference between SelectedItem

label4.Content = comboBox2.SelectedItem.ToString();
label5.Content = "Index " + comboBox2.SelectedIndex + " Text "+ comboBox2.Text;

Combobox.text shows that text displays that value prior to selection changed, where as  SelectedItem shows the current value. With DataContext binding the data members are follow the binding rules and may not be shared therefore it would show the source type, than value of the selected combobox item.