Skip to content

Commit 30bf4f3

Browse files
authored
Merge pull request #809 from shaosu/patch-1
Badge Maximum改变时会影响到Value的显示
2 parents c96936e + 9f07f98 commit 30bf4f3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • src/Shared/HandyControl_Shared/Controls/Other

src/Shared/HandyControl_Shared/Controls/Other/Badge.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@ public BadgeStatus Status
6363
}
6464

6565
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
66-
"Maximum", typeof(int), typeof(Badge), new PropertyMetadata(ValueBoxes.Int99Box, OnValueChanged));
67-
66+
"Maximum", typeof(int), typeof(Badge), new PropertyMetadata(ValueBoxes.Int99Box, OnMaximumChanged));
67+
68+
private static void OnMaximumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
69+
{
70+
var ctl = (Badge) d;
71+
var v = ctl.Value;
72+
ctl.SetCurrentValue(TextProperty, v <= ctl.Maximum ? v.ToString() : $"{ctl.Maximum}+");
73+
}
74+
6875
public int Maximum
6976
{
7077
get => (int) GetValue(MaximumProperty);

0 commit comments

Comments
 (0)