条目上的 Xamarin Stepper 增量

Xamarin Stepper increment on Entry

我想要一个步进器 increase/decrease 条目中的值。我在网上参考了其他帖子,但我的增量不起作用。我是否需要在 Entry 中增加值的代码?

xaml

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


 <Stepper x:Name="stepper" Minimum="1" Maximum="4" Increment="1"/>

需要在entry上写stepper的值吗?如果正确,那么您需要创建一个绑定值,因为当值更改时您需要 "listening" 并将此值放在条目上。

here there is an explain for this.

您需要将 Entry 的 Text 属性 绑定到 Stepper 的 value 属性

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


<Stepper x:Name="stepper" Minimum="1" Maximum="4" Increment="1"/>