How do I use WPF bindings with RelativeSource?

If you want to bind to another property on the object: {Binding Path=PathToProperty, RelativeSource={RelativeSource Self}} If you want to get a property on an ancestor: {Binding Path=PathToProperty, RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}} If you want to get a property on the templated parent (so you can do 2 way bindings in a ControlTemplate) {Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}} … Read more

Difference between SelectedItem, SelectedValue and SelectedValuePath

Their names can be a bit confusing :). Here’s a summary: The SelectedItem property returns the entire object that your list is bound to. So say you’ve bound a list to a collection of Category objects (with each Category object having Name and ID properties). eg. ObservableCollection<Category>. The SelectedItem property will return you the currently … Read more

sender as in C# [duplicate]

An event’s sender is just passed to the event handler as an object. Now when that event is raised, you usually know what kind of sender you can expect (since you set up the event handler yourself), but the method still requires an object type. Now the as is a type conversion that tries to … Read more