I'd like to be able to validate the RecurrenceRule, especially the RecursUntil part which should not be greater than a certain fixed date in the future. I've seen plenty of examples regarding the validation of a custom appointment but i couldn't find anything regarding the RecurrenceRule.
So far what i've found is that i could possibly inherit from RecurrenceDialogViewModel and override the CanConfirm method, but i couldn't find the points where i could attach myself.
I also tried to attach myself to the PropertyChanged event of the RecurrenceDialogViewModel to disallow the change with an alert, but the RecurrenDialog gets in the way!
Here is the code sample i used to check the RecursUntil
When you run this code with this method attached to the OpenDialog event of the RadScheduler, the alert window is pushed back between the edit appointment window and the edit reccurence window. Is it a bug, or have i forgotten something (saying the alert to be topmost?)
So far what i've found is that i could possibly inherit from RecurrenceDialogViewModel and override the CanConfirm method, but i couldn't find the points where i could attach myself.
I also tried to attach myself to the PropertyChanged event of the RecurrenceDialogViewModel to disallow the change with an alert, but the RecurrenDialog gets in the way!
Here is the code sample i used to check the RecursUntil
private
void
RSVPlanning_ShowDialog(
object
sender, ShowDialogEventArgs e)
{
var rdvm = e.DialogViewModel
as
RecurrenceDialogViewModel;
if
(rdvm !=
null
)
{
if
(rdvm.RecurrenceRangeType == RecurrenceRangeType.NoEndDate)
{
// we don't want the "no ending mode" and it's hidden in the template
rdvm.RecurrenceRangeType = RecurrenceRangeType.RepeatUntil;
rdvm.RecursUntil = DateTime.Now.AddDays(7);
}
rdvm.PropertyChanged += ((innerSender, pcea) => {
if
(pcea.PropertyName ==
"RecursUntil"
)
{
var rdvmCallback = innerSender
as
RecurrenceDialogViewModel;
if
(rdvmCallback.RecursUntil > DateTime.Now.AddDays(7))
{
RadWindow.Alert(
"That's too far away! Back to one week from now"
);
rdvmCallback.RecursUntil = DateTime.Now.AddDays(7);
}
}
});
}
}