Property always default

I have created a Xaml View which has a label on.

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="DrawShape.AnimatedLabel">
    <ContentView.Content>
        <Label x:Name="Lbl" Text="{Binding Count, StringFormat='{0:##,###} Steps'}"  />
    </ContentView.Content>
</ContentView>

In the Code behind page I have added a property to use :

        public static readonly BindableProperty EndValueProperty = BindableProperty.Create<AnimatedLabel, int> (s => s.EndValue, 0, BindingMode.TwoWay);

        public int EndValue {
            get{ return (int)GetValue (EndValueProperty); }
            set{ SetValue (EndValueProperty, value); }
        }

In my page, I create a Animated Label and assign a value to the property:

     <ViewCell.View>
          <controls:AnimatedLabel  EndValue="2500" />
     </ViewCell.View>

This builds fine, and the label appears on the screen - but when I debug the code the property 'EndValue' is always 0. Why is the value I have assigned to it not been passed through?

Cheers Ash

Tagged:
Sign In or Register to comment.