dotnet/maui · error · InvalidOperationException
MinimumDate must be lower than MaximumDate
Error message
MinimumDate must be lower than MaximumDate
What it means
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.
Source
Thrown at src/Compatibility/Core/src/GTK/Controls/DatePicker.cs:186
public RangeCalendar()
{
_minimumDate = new DateTime(1900, 1, 1);
_maximumDate = new DateTime(2199, 1, 1);
}
public DateTime MinimumDate
{
get
{
return _minimumDate;
}
set
{
if (MaximumDate < value)
{
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)}");View on GitHub (pinned to f377ff1c5e)
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.
Example fix
// before — min above existing max picker.MaximumDate = DateTime.Today; picker.MinimumDate = DateTime.Today.AddDays(30); // throws // after — raise the max first picker.MaximumDate = DateTime.Today.AddDays(60); picker.MinimumDate = DateTime.Today.AddDays(30);
Defensive patterns
Strategy: validation
Validate before calling
static void SafeSetMinimum(DateTimePicker picker, DateTime value)
{
if (value > picker.MaximumDate) picker.MaximumDate = value;
picker.MinimumDate = value;
} Try / catch
try { picker.MinimumDate = newMin; }
catch (InvalidOperationException) { picker.MaximumDate = newMin; picker.MinimumDate = newMin; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- MaximumDate must be greater than MinimumDate
- 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/4e32af39ffbd301a.
Report an issue: GitHub.