private static void OnLocationDisplayPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctrl = (LocationDisplayToggle)d;
if (e.NewValue != null)
{
var b = new Binding()
{
Source = e.NewValue,
Path = new PropertyPath("IsEnabled"),
Mode = BindingMode.TwoWay
};
ctrl.SetBinding(IsLocationEnabledProperty, b);
b = new Binding()
{
Source = e.NewValue,
Path = new PropertyPath("AutoPanMode"),
Mode = BindingMode.TwoWay
};
ctrl.SetBinding(ModeProperty, b);
}
else
{
ctrl.SetBinding(IsLocationEnabledProperty, null);
ctrl.SetBinding(ModeProperty, null);
}
ctrl.UpdateIcon();
}