【发布时间】:2019-09-23 10:16:16
【问题描述】:
我有一个这样的自定义控件:
<controls:CustomControl Value=".8" MaxValue=".7"/>
这是Value 可绑定属性:
public static readonly BindableProperty ValueProperty =
BindableProperty.Create(nameof(Value), typeof(double), typeof(CustomControl), 2d,
coerceValue: (bindable, value) =>
((double)value).Clamp(0.05d, ((CustomControl)bindable).MaxValue));
问题是它只有在 Value 更改时才会被评估,这不起作用:
<controls:CustomControl Value=".8" MaxValue=".7"/>
但这会:
<controls:CustomControl MaxValue=".7" Value=".8"/>
当另一个属性更改时(即在其propertyChanged 中),是否有办法执行coerceValue?
【问题讨论】:
-
不,我没有解决
-
您可以分享样本,以便我可以测试它。
标签: xamarin xamarin.forms bindableproperty