{"record":{"id":"13fc059168e0ad1b","repo":"dotnet/maui","slug":"maximumdate-must-be-greater-than-minimumdate","errorCode":null,"errorMessage":"MaximumDate must be greater than MinimumDate","messagePattern":"MaximumDate must be greater than MinimumDate","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/GTK/Controls/DatePicker.cs","lineNumber":204,"sourceCode":"\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)}\");\n\t\t\t\t\t}\n\n\t\t\t\t\t_maximumDate = value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tprotected override void OnDaySelected()\n\t\t\t{\n\t\t\t\tif (Date < MinimumDate)\n\t\t\t\t{\n\t\t\t\t\tDate = MinimumDate;\n\t\t\t\t}\n\n\t\t\t\tif (Date > MaximumDate)\n\t\t\t\t{\n\t\t\t\t\tDate = MaximumDate;\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/GTK/Controls/DatePicker.cs#L186-L222","documentation":"The GTK DatePicker MaximumDate setter validates that the new MaximumDate is not below the existing MinimumDate (condition `MinimumDate > value`). Setting MaximumDate below the current MinimumDate throws InvalidOperationException. It is the symmetric counterpart to the MinimumDate setter.","triggerScenarios":"Assigning MaximumDate to a value less than the current MinimumDate — e.g. MinimumDate is DateTime.Today and you set MaximumDate to a past date.","commonSituations":"Binding MinimumDate/MaximumDate from data where max crosses below min; setting MaximumDate before lowering MinimumDate; timezone/UTC conversion that shifts a date below the floor.","solutions":["Lower MinimumDate (or set it) before lowering MaximumDate to preserve min <= max.","Validate the incoming MaximumDate against the current MinimumDate before assignment.","Clamp rather than throw when the value comes from an untrusted source."],"exampleFix":"// before — max below existing min\npicker.MinimumDate = DateTime.Today;\npicker.MaximumDate = DateTime.Today.AddDays(-30); // throws\n// after — lower the min first\npicker.MinimumDate = DateTime.Today.AddDays(-60);\npicker.MaximumDate = DateTime.Today.AddDays(-30);","handlingStrategy":"validation","validationCode":"static void SafeSetMaximum(DateTimePicker picker, DateTime value)\n{\n    if (value < picker.MinimumDate) picker.MinimumDate = value;\n    picker.MaximumDate = value;\n}","typeGuard":null,"tryCatchPattern":"try { picker.MaximumDate = newMax; }\ncatch (InvalidOperationException) { picker.MinimumDate = newMax; picker.MaximumDate = newMax; }","preventionTips":["Lower MinimumDate before lowering MaximumDate.","Validate incoming max against current min.","Use a converter to keep both bounds consistent under binding.","Unit-test edge transitions of the date range."],"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"}