Hello,
I'm using a RadScheduleView in my project, and it works fine most of the time. But I have had two cases where I get a System.ArgumentException right at the begining when I load my app, whitout being able to do anything about it.
some details :
my app opens at first on a screen containing a radScheduleView.
the radScheduleView is mannulay set to the user's preference (what views he wants, what dayStartTime / dayEndTime, FirstDayOfWeek etc...) in code behind
so what I do is I clear the ViewDefinitionsCollection and then add exactly the views I want, depending on those settings.
here is the function that adds the ViewDefinitions :
as far as I can tell, this code should work fine to add new ViewDefinitions to the collection, but for whatever reason I get this Exception. I could catch it and move on but then again, I'd rather know what goes wrong than try to ignore it.
thanks
I'm using a RadScheduleView in my project, and it works fine most of the time. But I have had two cases where I get a System.ArgumentException right at the begining when I load my app, whitout being able to do anything about it.
some details :
my app opens at first on a screen containing a radScheduleView.
the radScheduleView is mannulay set to the user's preference (what views he wants, what dayStartTime / dayEndTime, FirstDayOfWeek etc...) in code behind
so what I do is I clear the ViewDefinitionsCollection and then add exactly the views I want, depending on those settings.
here is the function that adds the ViewDefinitions :
/// <summary>
/// Adds a new ViewDefinition in the Collection
/// </summary>
/// <param name="viewDefinitionId">id of the view</param>
/// <param name="viewDefinitionName">display text for the view (localized)</param>
private
void
AddViewDefinition(
int
viewDefinitionId,
string
viewDefinitionName)
{
ViewDefinitionBase viewDefinition =
null
;
int
activeViewDefinitionIndex = ScheduleView.ActiveViewDefinitionIndex;
switch
(viewDefinitionId)
{
case
0: ScheduleView.ViewDefinitions.Add(viewDefinition =
new
DayViewDefinition { Title = viewDefinitionName, TimerulerMajorTickStringFormat =
"{0:t} "
});
break
;
case
1: ScheduleView.ViewDefinitions.Add(viewDefinition =
new
WeekViewDefinition { Title = viewDefinitionName, TimerulerMajorTickStringFormat =
"{0:t} "
});
break
;
case
2: ScheduleView.ViewDefinitions.Add(viewDefinition =
new
WeekViewDefinition
{
Title = viewDefinitionName,
TimerulerMajorTickStringFormat =
"{0:t} "
,
GroupFilter = obj =>
{
if
(obj
is
DateTime)
{
var day = ((DateTime)obj).DayOfWeek.GetRecurrenceDay();
return
(day & WorkingDays) == day;
}
return
true
;
}
});
break
;
case
3: ScheduleView.ViewDefinitions.Add(viewDefinition =
new
MonthViewDefinition { Title = viewDefinitionName });
break
;
}
if
(viewDefinition ==
null
)
return
;
viewDefinition.SetValue(IdProperty, viewDefinitionId);
viewDefinition.SetValue(DayViewDefinition.EnableSmallAppointmentRenderingProperty,
true
);
ScheduleView.ActiveViewDefinitionIndex = activeViewDefinitionIndex;
}
and the Issue I have seems to lies within this function (see attached screenshot for details on the exception)
do you have any idea what is happening here? (I don't)
as far as I can tell, this code should work fine to add new ViewDefinitions to the collection, but for whatever reason I get this Exception. I could catch it and move on but then again, I'd rather know what goes wrong than try to ignore it.
thanks