Problem with binding Stepper to Dictionary

Hello
i have a problem to bind Stepper to Dictionary in code behind . when i try to bind it i receive this error

Object reference not set to an instance of an object

i can bind TextProperty of Entry to the Dictionary but for Stepper I can't

This Code work for Entry:

Entry = new Entry { HeightRequest = 40,HorizontalOptions = LayoutOptions.FillAndExpand};
StackLayoutMap.Children.Add(Entry);
Entry.SetBinding(Entry.TextProperty, "Dictionary[" + item.FieldID.ToString() + "]");

But this Code doesn't work for Stepper

Stepper = new Stepper();
StackLayoutMap.Children.Add(Stepper);
Stepper.SetBinding(Stepper.ValueProperty,"Dictionary[" + item.FieldID.ToString() + "]");

Answers

  • seanydaseanyda GBMember ✭✭✭✭✭
    edited October 16

    @AfshinHaftlangi said:
    Hello
    i have a problem to bind Stepper to Dictionary in code behind . when i try to bind it i receive this error

    Object reference not set to an instance of an object

    i can bind TextProperty of Entry to the Dictionary but for Stepper I can't

    This Code work for Entry:

    Entry = new Entry { HeightRequest = 40,HorizontalOptions = LayoutOptions.FillAndExpand};
    StackLayoutMap.Children.Add(Entry);
    Entry.SetBinding(Entry.TextProperty, "Dictionary[" + item.FieldID.ToString() + "]");

    But this Code doesn't work for Stepper

    Stepper = new Stepper();
    StackLayoutMap.Children.Add(Stepper);
    Stepper.SetBinding(Stepper.ValueProperty,"Dictionary[" + item.FieldID.ToString() + "]");

    Isn't the Stepper value property an double? So you shouldn't be converting it into a string. Also correct if I'm wrong but you'll want to be binding from the model so get the property name and do

    Stepper.SetBinding(Stepper.ValueProperty, new Binding("PROPERTYNAME"));

  • AfshinHaftlangiAfshinHaftlangi USMember ✭✭

    @seanyda
    the stepper value is double . but i need to bind it to this property

    public Dictionary<string, object> Dictionary { get; set; }

    i have form with different fields and i want to get all value of the fields in Dictionary

Sign In or Register to comment.