dotnet/maui · error · InvalidOperationException
MaximumDate must be greater than MinimumDate
Error message
MaximumDate must be greater than MinimumDate
What it means
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.
Source
Thrown at src/Compatibility/Core/src/GTK/Controls/DatePicker.cs:204
throw new InvalidOperationException($"{nameof(MinimumDate)} must be lower than {nameof(MaximumDate)}");
}
_minimumDate = value;
}
}
public DateTime MaximumDate
{
get
{
return _maximumDate;
}
set
{
if (MinimumDate > value)
{
throw new InvalidOperationException($"{nameof(MaximumDate)} must be greater than {nameof(MinimumDate)}");
}
_maximumDate = value;
}
}
protected override void OnDaySelected()
{
if (Date < MinimumDate)
{
Date = MinimumDate;
}
if (Date > MaximumDate)
{
Date = MaximumDate;
}
}View on GitHub (pinned to f377ff1c5e)
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.
Example fix
// before — max below existing min picker.MinimumDate = DateTime.Today; picker.MaximumDate = DateTime.Today.AddDays(-30); // throws // after — lower the min first picker.MinimumDate = DateTime.Today.AddDays(-60); picker.MaximumDate = DateTime.Today.AddDays(-30);
Defensive patterns
Strategy: validation
Validate before calling
static void SafeSetMaximum(DateTimePicker picker, DateTime value)
{
if (value < picker.MinimumDate) picker.MinimumDate = value;
picker.MaximumDate = value;
} Try / catch
try { picker.MaximumDate = newMax; }
catch (InvalidOperationException) { picker.MinimumDate = newMax; picker.MaximumDate = newMax; } Prevention
- 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.
When it happens
Trigger: Assigning MaximumDate to a value less than the current MinimumDate — e.g. MinimumDate is DateTime.Today and you set MaximumDate to a past date.
Common situations: 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.
Related errors
- MinimumDate must be lower than MaximumDate
- OpenGL dll not found!
- Glx entry point not found!
- call Forms.Init() before this
- call GtkThemes.Init() before this
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/13fc059168e0ad1b.
Report an issue: GitHub.