{"record":{"id":"8a04a0f33c4ccd60","repo":"MaterialDesignInXAML/MaterialDesignInXamlToolkit","slug":"minuteselectionstep-must-be-a-divisor-of-60-and-be","errorCode":null,"errorMessage":"MinuteSelectionStep must be a divisor of 60 and between 1 and 60.","messagePattern":"MinuteSelectionStep must be a divisor of 60 and between 1 and 60\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/MaterialDesignThemes.Wpf/Clock.cs","lineNumber":250,"sourceCode":"        nameof(CornerRadius), typeof(CornerRadius), typeof(Clock), new PropertyMetadata(default(CornerRadius)));\n\n    public CornerRadius CornerRadius\n    {\n        get => (CornerRadius)GetValue(CornerRadiusProperty);\n        set => SetValue(CornerRadiusProperty, value);\n    }\n\n    public static readonly DependencyProperty MinuteSelectionStepProperty = DependencyProperty.Register(\n        nameof(MinuteSelectionStep), typeof(int),typeof(Clock), new PropertyMetadata(1, MinuteSelectionStepPropertyChangedCallback));\n\n    private static void MinuteSelectionStepPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)\n    {\n        var clock = (Clock)d;\n\n        int step = (int)e.NewValue;\n\n        if (step < 1 || step > 60 || 60 % step != 0)\n            throw new ArgumentOutOfRangeException(\n                nameof(MinuteSelectionStep),\n                $\"{nameof(MinuteSelectionStep)} must be a divisor of 60 and between 1 and 60.\");\n\n        clock.GenerateButtons();\n    }\n\n    public int MinuteSelectionStep\n    {\n        get => (int)GetValue(MinuteSelectionStepProperty);\n        set => SetValue(MinuteSelectionStepProperty, value);\n    }\n\n    public static readonly RoutedEvent ClockChoiceMadeEvent =\n        EventManager.RegisterRoutedEvent(\n            \"ClockChoiceMade\",\n            RoutingStrategy.Bubble,\n            typeof(ClockChoiceMadeEventHandler),\n            typeof(Clock));","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/98edec3a0b96ef272c587b14bcd67ef5f928a7ed/src/MaterialDesignThemes.Wpf/Clock.cs#L232-L268","documentation":"`Clock.MinuteSelectionStep` is a `DependencyProperty` whose change callback validates the new int: it must be in [1,60] and divide 60 evenly, else `ArgumentOutOfRangeException`. Because the validation lives in the property-changed callback (not a `ValidateValueCallback`), an invalid value set via XAML/binding is assigned first and then the callback throws, which can surface as an unhandled XAML parse or binding exception.","triggerScenarios":"Setting `MinuteSelectionStep` to 0, a value > 60, or a non-divisor of 60 such as 7, 9, 11, 13; providing it via XAML attribute, style setter, or binding.","commonSituations":"User/designer types `MinuteSelectionStep=\"7\"` in XAML thinking any minute step works; binding to a preference that allows arbitrary ints; copying a value from a 24-hour or seconds-based control.","solutions":["Use a valid divisor of 60 within 1-60: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, or 60.","Constrain the source of any binding to that same set (an enum or validated combo box).","If allowing arbitrary steps, snap to the nearest valid divisor before assigning.","Consider replacing the throw with `CoerceValueCallback` that clamps the value, so invalid input degrades gracefully instead of throwing."],"exampleFix":"// before\n<mdtc:Clock MinuteSelectionStep=\"7\" /> <!-- throws -->\n\n// after\n<mdtc:Clock MinuteSelectionStep=\"5\" />","handlingStrategy":"validation","validationCode":"static readonly HashSet<int> ValidSteps =\n    new() { 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 };\nint step = desiredStep;\nif (!ValidSteps.Contains(step)) step = 1; // safe default\nclock.MinuteSelectionStep = step;","typeGuard":"static bool IsValidMinuteStep(int step)\n    => step >= 1 && step <= 60 && 60 % step == 0;","tryCatchPattern":null,"preventionTips":["Restrict MinuteSelectionStep to divisors of 60 within 1-60.","Bind from a constrained source (enum/combo) so invalid values can't be chosen.","Prefer a CoerceValueCallback over throwing in the changed callback for dependency properties."],"tags":["wpf","dependency-property","clock","time-picker","validation","material-design"],"backgroundTag":null,"analyzedSha":"98edec3a0b96ef272c587b14bcd67ef5f928a7ed","analyzedAt":"2026-08-13T14:31:19.111Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}