WPF: instances of sharecontrol usercontrol dependency properties

I created a usercontrol and it works fine, but when I put two instances of this control in one window, only the last one works. I tried to find a solution, and I realized that dependency properties are common, but I don't know how to make it work.

Here is my dependency property:

    public double AnimatingVerticalOffset
    {
        get { return (double)GetValue(AnimatingVerticalOffsetProperty); }
        set { SetValue(AnimatingVerticalOffsetProperty, value); }
    }

    public static readonly DependencyProperty AnimatingVerticalOffsetProperty;

    static ListChooser()
    {
        ListChooser.AnimatingVerticalOffsetProperty =
                   DependencyProperty.Register("AnimatingVerticalOffset", typeof(double), typeof(ListChooser), new UIPropertyMetadata(OnAnimationVerticalOffsetChanged));
    }
+3
source share
1 answer

, . (OnAnimationVerticalOffsetChanged ) - ( , , - , , , ).

DP, ( ), DP .

. .

:

:

public double AnimatingVerticalOffset
{
    get { return (double)GetValue(AnimatingVerticalOffsetProperty); }
    set { SetValue(AnimatingVerticalOffsetProperty, value); }
}

public static readonly DependencyProperty AnimatingVerticalOffsetProperty =
               DependencyProperty.Register("AnimatingVerticalOffset", typeof(double), typeof(ListChooser), new UIPropertyMetadata(OnAnimationVerticalOffsetChanged));

static ListChooser()
{
}

, (= > ).

EDIT:

, DP , ! DP , , : inhertiance, bidnings, animation...

+2

Source: https://habr.com/ru/post/1790995/


All Articles