Maximum改变时会影响到Value的显示

MaximumProperty应设置独立的回调
This commit is contained in:
shaosu authored and GitHub committed 2021-05-03 16:53:38 +08:00
1 parent f472822b0b
commit 2a5d70e95b
1 file changed
+9 -2
@@ -63,8 +63,15 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
"Maximum", typeof(int), typeof(Badge), new PropertyMetadata(ValueBoxes.Int99Box, OnValueChanged));
"Maximum", typeof(int), typeof(Badge), new PropertyMetadata(ValueBoxes.Int99Box, OnMaximumValueChanged));
private static void OnMaximumValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (Badge) d;
var v = ctl.Value;
ctl.SetCurrentValue(TextProperty, v <= ctl.Maximum ? v.ToString() : $"{ctl.Maximum}+");
}
public int Maximum
{
get => (int) GetValue(MaximumProperty);