{"record":{"id":"4e32af39ffbd301a","repo":"dotnet/maui","slug":"minimumdate-must-be-lower-than-maximumdate","errorCode":null,"errorMessage":"MinimumDate must be lower than MaximumDate","messagePattern":"MinimumDate must be lower than MaximumDate","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/GTK/Controls/DatePicker.cs","lineNumber":186,"sourceCode":"\n\t\t\tpublic RangeCalendar()\n\t\t\t{\n\t\t\t\t_minimumDate = new DateTime(1900, 1, 1);\n\t\t\t\t_maximumDate = new DateTime(2199, 1, 1);\n\t\t\t}\n\n\t\t\tpublic DateTime MinimumDate\n\t\t\t{\n\t\t\t\tget\n\t\t\t\t{\n\t\t\t\t\treturn _minimumDate;\n\t\t\t\t}\n\n\t\t\t\tset\n\t\t\t\t{\n\t\t\t\t\tif (MaximumDate < value)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new InvalidOperationException($\"{nameof(MinimumDate)} must be lower than {nameof(MaximumDate)}\");\n\t\t\t\t\t}\n\n\t\t\t\t\t_minimumDate = value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpublic DateTime MaximumDate\n\t\t\t{\n\t\t\t\tget\n\t\t\t\t{\n\t\t\t\t\treturn _maximumDate;\n\t\t\t\t}\n\n\t\t\t\tset\n\t\t\t\t{\n\t\t\t\t\tif (MinimumDate > value)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new InvalidOperationException($\"{nameof(MaximumDate)} must be greater than {nameof(MinimumDate)}\");","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/GTK/Controls/DatePicker.cs#L168-L204","documentation":"The GTK DatePicker control's MinimumDate setter validates that the new MinimumDate is not above the existing MaximumDate (condition `MaximumDate < value`). Setting MinimumDate above the current MaximumDate throws InvalidOperationException. The check uses the live MaximumDate property, so order of setting matters.","triggerScenarios":"Assigning MinimumDate to a value greater than the current MaximumDate — e.g. MaximumDate is DateTime.Today and you set MinimumDate to a week from now.","commonSituations":"Initializing DatePicker bounds from data where the min ends up above the max; setting MinimumDate before raising MaximumDate; binding both from a source where they cross.","solutions":["Set MaximumDate first (or widen it) before raising MinimumDate, or lower MinimumDate before lowering MaximumDate to keep the invariant min <= max.","Validate the incoming value against the current MaximumDate before assignment.","Clamp the value rather than throwing if the source is untrusted."],"exampleFix":"// before — min above existing max\npicker.MaximumDate = DateTime.Today;\npicker.MinimumDate = DateTime.Today.AddDays(30); // throws\n// after — raise the max first\npicker.MaximumDate = DateTime.Today.AddDays(60);\npicker.MinimumDate = DateTime.Today.AddDays(30);","handlingStrategy":"validation","validationCode":"static void SafeSetMinimum(DateTimePicker picker, DateTime value)\n{\n    if (value > picker.MaximumDate) picker.MaximumDate = value;\n    picker.MinimumDate = value;\n}","typeGuard":null,"tryCatchPattern":"try { picker.MinimumDate = newMin; }\ncatch (InvalidOperationException) { picker.MaximumDate = newMin; picker.MinimumDate = newMin; }","preventionTips":["Set MaximumDate before raising MinimumDate.","Validate incoming min against current max.","Bind with a value converter that clamps/adjusts both bounds together.","Centralize date-bound assignment in one helper."],"tags":["gtk","datepicker","validation","date-range","maui-compat"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}