http://www.codeproject.com/KB/WPF/WpfDataBinding1.aspx
Introduction to all aspects of WPF binding.
http://msdn.microsoft.com/en-us/library/ms752347.aspx#basic_data_binding_concepts
Data binding overview.
http://www.codeproject.com/KB/WPF/GuidedTourWPF_3.aspx
CodePlex solid introduction to data binding.
http://blogs.msdn.com/b/wpfsdk/archive/2007/03/21/wha-happened-part-two-more-property-changes-in-wpf.aspx
http://blogs.msdn.com/b/wpfsdk/archive/2007/03/21/wha-happened-part-two-more-property-changes-in-wpf.aspx
Run through of the different ways of notifying a data change in WPF
http://stackoverflow.com/questions/561166/binding-wpf-combobox-to-a-custom-list
To bind the data to ComboBox
List<ComboData> ListData = new List<ComboData>();
ListData.Add(new ComboData { Id = "1", Value = "One" });
ListData.Add(new ComboData { Id = "2", Value = "Two" });
istData.Add(new ComboData { Id = "3", Value = "Three" });
ListData.Add(new ComboData { Id = "4", Value = "Four" });
ListData.Add(new ComboData { Id = "5", Value = "Five" });
cbotest.ItemsSource = ListData;
cbotest.DisplayMemberPath = "Value";
cbotest.SelectedValuePath = "Id";
cbotest.SelectedValue = "2";
http://japikse.blogspot.com/2008/10/wpf-combobox-selecteditem-selectedvalue.html
Recently, I received a question from one of my twitter tribemates on using the ComboBox in WPF with objects, and it centered around the difference between the SelectedValue, SelectedValuePath, and SelectedItem properties. This post will go through the differences, and how they are used, and also do a little review on databinding in WPF.
Specific example of parent detail binding in both directions.
http://blog.cylewitruk.com/2010/09/wpf-combobox-and-databinding-datacontext-itemssource-displaymemberpath-selecteditem-selectedvalue-selectedvaluepath/
Now, all of that aside, let’s go over the more common properties used in DataBinding to a Selector control. Note that when I refer to the ViewModel I’m assuming that the DataContext of the page is set to your ViewModel instance and that the ComboBox has inherited that DataContext.
http://msdn.microsoft.com/en-us/library/dd409789.aspx
WPF Tree Visualiser
http://stackoverflow.com/questions/2802662/any-reason-why-presentationtracesources-tracelevel-high-would-not-print-any-info
WPF debugging.
<Window xmlns:diag=”clr-namespace:System.Diagnostics;assembly=WindowsBase” />
…
<TextBlock Text=”{Binding Path=x, diag:PresentationTraceSources.TraceLevel=High}” />
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/195c61af-d658-461f-b509-733315807e05
SelectedItem binding to last item using CollectionView override.
http://www.telerik.com/community/forums/wpf/combobox/valuepath-property.aspx
Selected Value Path property binding.
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/4efab5ae-0a12-48c3-b8bd-4acc73bfb10d
Binding in code.
Binding b = new Binding();
b.Source = pre;
b.Path = new PropertyPath(“DisplayName”);
b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
b.Mode = BindingMode.TwoWay;
this.SetBinding(IdentityCard.DisplayNameProperty, b);
http://stackoverflow.com/questions/6145511/two-way-binding-problem-with-wpf-combobox-using-mvvm
public override bool Equals(object otherObject)
{ if (!(otherObject is ActivityStatus))
return false;
return Equals(otherObject as ActivityStatus); }
public bool Equals(ActivityStatus otherStatus) {
if (!(otherStatus is ActivityStatus) ||
otherStatus == null) return false;
return Id == otherStatus.Id &&
Name == otherStatus.Name; }
http://bea.stollnitz.com/blog/?p=9
<StackPanel Name=”mainStackPanel”>
<ListBox ItemsSource=”{Binding}” DisplayMemberPath=”Name” SelectedValue=”Messenger of the Gods” SelectedValuePath=”Description” Name=”listBox1″ (…) />
</StackPanel>
The difference between SelectedValue and SelectedItem should be obvious now. SelectedValue returns the string it was set to (“Messenger of the Gods”), while SelectedItem returns the actual GreekGod object with that description.
string messengerOfGods = (string)(listBox1.SelectedValue);
GreekGod hermes = (GreekGod)(listBox1.SelectedItem);
SelectedValue is particularly useful when only part of your item is stored in the model you are data binding to. In this scenario, you would data bind the SelectedValue property to the partial information in your model but the ListBox can show a lot more information about that item.