fix: fixed CoverView crash issue when the value of Groups is 0

This commit is contained in:
NaBian committed 2022-03-20 13:45:14 +08:00
1 parent fe89a9dfc8
commit 2babb718a6
1 file changed
+6 -7
@@ -108,7 +108,12 @@ public class CoverView : RegularItemsControl
internal static readonly DependencyProperty GroupsProperty = DependencyProperty.Register(
"Groups", typeof(int), typeof(CoverView),
new FrameworkPropertyMetadata(ValueBoxes.Int5Box, FrameworkPropertyMetadataOptions.AffectsMeasure,
OnGroupsChanged), IsGroupsValid);
OnGroupsChanged, CoerceGroups));
private static object CoerceGroups(DependencyObject d, object basevalue)
{
return (int) basevalue < 1 ? 1 : basevalue;
}
internal static void OnGroupsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
@@ -118,12 +123,6 @@ public class CoverView : RegularItemsControl
}
}
private static bool IsGroupsValid(object value)
{
var v = (int) value;
return v >= 1;
}
public int Groups
{
get => (int) GetValue(GroupsProperty);