Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to do two way binding in code behind/in C#?

$
0
0

I have a stepper control and I initializes it with value 5 in my viewmodel and here is the binding

Stepper stepper = new Stepper { Increment = 1};
stepper.SetBinding(Stepper.ValueProperty. new Binding(path: 'StepperValue', mode: BindingMode.TwoWay));

I have a label which is also listening to this StepperValue to display the values as the user presses + or - button. With the above code and having the initial value to set to 5, I was expecting when the user presses + for the first time, the StepperValue should turn to 6, but instead it turn to 1 as if the initial value is set to 0. Is there something I am doing wrong?

Also, can someone point me to the code where I can implement command pattern for stepper click event in the code behind? (I stopped using XAML purely because there is no intellisense support today).


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>