How to fix Xceed DateTimePicker ArgumentOutOfRangeException Error
I am using the Xceed DateTimePicker as the control in a wpf DataGrid for all columns that are bound to a Date property. Each of the those columns is defined as follows:
<DataGrid.Columns>
<DataGridTemplateColumn
Header="Charge Date"
Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=ChargeDate, StringFormat=yyyy-MM-dd, Converter={StaticResource conDate}}"
HorizontalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<tk:DateTimePicker Value="{Binding Path=ChargeDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
I don't think it is pertinent to my question, but for completeness sake, here is the styling for the pickers:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
This works for datagrid cells that are already populated or when I am entering data in a new row. However when I click on an empty cell in an existing row, I get the following exception:
System.ArgumentOutOfRangeException: 'SelectedDate value is not valid.'
Why is the error only when I am enter data in an existing row? No code-behind is being executed when this exception happens so I don't know where to look for the problem.
wpf datagrid datetimepicker xceed
add a comment |
I am using the Xceed DateTimePicker as the control in a wpf DataGrid for all columns that are bound to a Date property. Each of the those columns is defined as follows:
<DataGrid.Columns>
<DataGridTemplateColumn
Header="Charge Date"
Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=ChargeDate, StringFormat=yyyy-MM-dd, Converter={StaticResource conDate}}"
HorizontalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<tk:DateTimePicker Value="{Binding Path=ChargeDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
I don't think it is pertinent to my question, but for completeness sake, here is the styling for the pickers:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
This works for datagrid cells that are already populated or when I am entering data in a new row. However when I click on an empty cell in an existing row, I get the following exception:
System.ArgumentOutOfRangeException: 'SelectedDate value is not valid.'
Why is the error only when I am enter data in an existing row? No code-behind is being executed when this exception happens so I don't know where to look for the problem.
wpf datagrid datetimepicker xceed
add a comment |
I am using the Xceed DateTimePicker as the control in a wpf DataGrid for all columns that are bound to a Date property. Each of the those columns is defined as follows:
<DataGrid.Columns>
<DataGridTemplateColumn
Header="Charge Date"
Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=ChargeDate, StringFormat=yyyy-MM-dd, Converter={StaticResource conDate}}"
HorizontalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<tk:DateTimePicker Value="{Binding Path=ChargeDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
I don't think it is pertinent to my question, but for completeness sake, here is the styling for the pickers:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
This works for datagrid cells that are already populated or when I am entering data in a new row. However when I click on an empty cell in an existing row, I get the following exception:
System.ArgumentOutOfRangeException: 'SelectedDate value is not valid.'
Why is the error only when I am enter data in an existing row? No code-behind is being executed when this exception happens so I don't know where to look for the problem.
wpf datagrid datetimepicker xceed
I am using the Xceed DateTimePicker as the control in a wpf DataGrid for all columns that are bound to a Date property. Each of the those columns is defined as follows:
<DataGrid.Columns>
<DataGridTemplateColumn
Header="Charge Date"
Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Path=ChargeDate, StringFormat=yyyy-MM-dd, Converter={StaticResource conDate}}"
HorizontalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<tk:DateTimePicker Value="{Binding Path=ChargeDate}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
I don't think it is pertinent to my question, but for completeness sake, here is the styling for the pickers:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
This works for datagrid cells that are already populated or when I am entering data in a new row. However when I click on an empty cell in an existing row, I get the following exception:
System.ArgumentOutOfRangeException: 'SelectedDate value is not valid.'
Why is the error only when I am enter data in an existing row? No code-behind is being executed when this exception happens so I don't know where to look for the problem.
wpf datagrid datetimepicker xceed
wpf datagrid datetimepicker xceed
asked Sep 6 '17 at 9:01


SezMeSezMe
187114
187114
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Since you have set the Minimum
property to 2017-01-01
, you should also set the default value to the same date:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Default" Value="2017-01-01" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
You will get an ArgumentOutOfRangeException
if the default value or value is less than the minimum value and this makes perfect sense.
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
add a comment |
I had the same issue. To fix this set the ClipValueToMinMax property to "True". This will prevent the value from going below minimum/above maximum without throwing an exception.
<xceed:DateTimePicker Value="{Binding DateTime}"
Minimum="{Binding DateTimeMinimum}"
Maximum="{Binding DateTimeMaximum}"
ClipValueToMinMax="True"/>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46070932%2fhow-to-fix-xceed-datetimepicker-argumentoutofrangeexception-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since you have set the Minimum
property to 2017-01-01
, you should also set the default value to the same date:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Default" Value="2017-01-01" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
You will get an ArgumentOutOfRangeException
if the default value or value is less than the minimum value and this makes perfect sense.
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
add a comment |
Since you have set the Minimum
property to 2017-01-01
, you should also set the default value to the same date:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Default" Value="2017-01-01" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
You will get an ArgumentOutOfRangeException
if the default value or value is less than the minimum value and this makes perfect sense.
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
add a comment |
Since you have set the Minimum
property to 2017-01-01
, you should also set the default value to the same date:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Default" Value="2017-01-01" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
You will get an ArgumentOutOfRangeException
if the default value or value is less than the minimum value and this makes perfect sense.
Since you have set the Minimum
property to 2017-01-01
, you should also set the default value to the same date:
<Style TargetType="{x:Type tk:DateTimePicker}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="Default" Value="2017-01-01" />
<Setter Property="Minimum" Value="2017-01-01" />
<Setter Property="DisplayDefaultValueOnEmptyText" Value="False" />
<Setter Property="ShowButtonSpinner" Value="False" />
<Setter Property="TimePickerVisibility" Value="Collapsed" />
<Setter Property="AutoCloseCalendar" Value="True" />
<Setter Property="Format" Value="Custom" />
<Setter Property="FormatString" Value="yyyy-MM-dd" />
</Style>
You will get an ArgumentOutOfRangeException
if the default value or value is less than the minimum value and this makes perfect sense.
answered Sep 6 '17 at 10:04


mm8mm8
85.3k81932
85.3k81932
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
add a comment |
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
Excellent observation - I added the default value to the Style. However, I get the same exception!
– SezMe
Sep 6 '17 at 23:25
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
What cell are you clicking in when you get the exception? Please provide a repo of your issue: stackoverflow.com/help/mcve
– mm8
Sep 7 '17 at 9:20
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
OK, let me put together a sample.
– SezMe
Sep 7 '17 at 17:24
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
Update: I haven't forgotten this problem. I've stripped the solution down to the bare essentials, such as removing all the calls to the database, and in doing so I'm getting a lot of binding errors that I haven't traced down yet. But I'm still working on it. Maybe when I figure that out, I'll uncover the problem listed here.
– SezMe
Sep 11 '17 at 1:54
add a comment |
I had the same issue. To fix this set the ClipValueToMinMax property to "True". This will prevent the value from going below minimum/above maximum without throwing an exception.
<xceed:DateTimePicker Value="{Binding DateTime}"
Minimum="{Binding DateTimeMinimum}"
Maximum="{Binding DateTimeMaximum}"
ClipValueToMinMax="True"/>
add a comment |
I had the same issue. To fix this set the ClipValueToMinMax property to "True". This will prevent the value from going below minimum/above maximum without throwing an exception.
<xceed:DateTimePicker Value="{Binding DateTime}"
Minimum="{Binding DateTimeMinimum}"
Maximum="{Binding DateTimeMaximum}"
ClipValueToMinMax="True"/>
add a comment |
I had the same issue. To fix this set the ClipValueToMinMax property to "True". This will prevent the value from going below minimum/above maximum without throwing an exception.
<xceed:DateTimePicker Value="{Binding DateTime}"
Minimum="{Binding DateTimeMinimum}"
Maximum="{Binding DateTimeMaximum}"
ClipValueToMinMax="True"/>
I had the same issue. To fix this set the ClipValueToMinMax property to "True". This will prevent the value from going below minimum/above maximum without throwing an exception.
<xceed:DateTimePicker Value="{Binding DateTime}"
Minimum="{Binding DateTimeMinimum}"
Maximum="{Binding DateTimeMaximum}"
ClipValueToMinMax="True"/>
answered Nov 22 '18 at 10:18
Dries GeenenDries Geenen
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46070932%2fhow-to-fix-xceed-datetimepicker-argumentoutofrangeexception-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown