1

I want to have a stepper to increase/decrease the value in an Entry. I referenced to other posts online but my increment does not work. Do I need to have a code behind for the values to increase in Entry?

xaml

 <Entry BindingContext="{x:Reference stepper}" Text="1" />


 <Stepper x:Name="stepper" Minimum="1" Maximum="4" Increment="1"/>
Ris
  • 13
  • 2

2 Answers2

0

do you need write the value of stepper on the entry? if that right then you need create a binding value, because yo need "listening" when the value change and put this value on the entry.

here there is an explain for this.

  • The entry will have another value bound to it from the start and I want the stepper to increase/decrease the value. I can't open the link – Ris May 18 '20 at 03:51
0

you need to bind the Entry's Text property to the Stepper's value property

<Entry BindingContext="{x:Reference stepper}" Text="{Binding Value}" />


<Stepper x:Name="stepper" Minimum="1" Maximum="4" Increment="1"/>
Jason
  • 86,222
  • 15
  • 131
  • 146
  • Oh thank you so much it works! Can I ask if I want to get the value from entry after the increment, do I access it by using entry.Text in code too? – Ris May 18 '20 at 04:00
  • yes, or you could bind both controls to the same VM property – Jason May 18 '20 at 04:02