Binding for non hierarchical object
If you have an object who is not in herarchical tree, like converter, you cannot bind something even you have define DependyProperty on it.
first you must prepare you converter for having DependencyProperty by override DependencyObject
public class SelectionConverter : DependencyObject, IMultiValueConverter
then create DependencyProperties
#region Window (DP SHORT)
public object Window { get { return (object)GetValue(WindowProperty); } set { SetValue(WindowProperty, value); } }
public static readonly DependencyProperty WindowProperty = DependencyProperty.Register("Window", typeof(object), typeof(SelectionConverter), new PropertyMetadata(null));
#endregion
#region Name (DP SHORT)
public object Name { get { return (object)GetValue(NameProperty); } set { SetValue(NameProperty, value); } }
public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(object), typeof(SelectionConverter), new PropertyMetadata(null));
#endregion
and finally set binding in xaml
as the converter is not in herarchical tree i cannot using binding with ElementName= but i can use x:reference like this
<local:SelectionConverter x:Key="sc"
x:Shared="false"
Window="{Binding ., Source={x:Reference win}}"
Name="{Binding Content, Source={x:Reference cb}}" />
