Custom control: BindableProperty doesn't seems to be bound

Ben.2646Ben.2646 USMember ✭✭

Hello,

I'm working on a custom control.
This custom control has a "Value" property.
Here is my control cs file:

public partial class Duration : Grid, INotifyPropertyChanged
{
    public static readonly BindableProperty ValueProperty = BindableProperty.Create("Value", typeof(int), typeof(Duration), default(int), defaultBindingMode: BindingMode.TwoWay);
    public int Value
    {
        get { return (int)GetValue(ValueProperty); }
        set { SetValue(ValueProperty, value); }
    }

    ....
}

And here is my xaml where I use my control (where I make the binding):
<controls:Duration Value="{Binding duration, Mode=TwoWay}"/>

And here is my bound property:

        private int _duration = 6546;
        public int duration
        {
            get { return _duration; }
            set
            {
                if (_duration == value)
                    return;

                _duration = value;
                RaisePropertyChanged(() => duration);
            }
        }

My problem is that my duration property is never updated. I've added breakpoint (in Visual Studio) and they are never reached.
What's wrong with my ValueProperty ?

Best Answers

Answers

Sign In or Register to comment.