Get or set Accessor Attached Property without activating data binding? WPF

I have a custom Attached property, but Accessors never access the data binding. Are these assemblers available every time a related property changes?

  public static readonly DependencyProperty CharacterColumnNumberProperty =
        DependencyProperty.RegisterAttached("CharacterColumnNumber", typeof(int), typeof(DragCanvas), new UIPropertyMetadata(1));

    public static int GetCharacterColumnNumber(UIElement uiElement)
    {
        if (uiElement != null)
            return (int)uiElement.GetValue(CharacterColumnNumberProperty);
        else return 0;
    }

    public static void SetCharacterColumnNumber(UIElement uiElement, int value)
    {
        if (uiElement != null)
        {
            uiElement.SetValue(CharacterColumnNumberProperty, value);
            DragCanvas.SetLeft(uiElement, value * 10);
        }
    }

      

XAML:

 <Setter Property="local:DragCanvas.CharacterColumnNumber" Value="{Binding Path=CharacterColumnNumber, Mode=TwoWay}" />

      

+2


source to share


1 answer


No, it is not. If you want to know when the backend property engine changes these values, you pass a delegate for the PropertyChangedCallback parameter of the UIPropertyMetadata.



This delegate will be called every time the property is changed, whether it was through a CLR property or internal changes in the dependency property mechanism (i.e. bindings).

+4


source







All Articles