This is a migrated thread and some comments may be shown as answers.

ScheduleView in TabControl: exception

4 Answers 86 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Massimiliano Giustizieri
Top achievements
Rank 1
Massimiliano Giustizieri asked on 15 Jun 2011, 10:51 AM
Dear Telerik Team,

in our product we make extensive use of the ScheduleView. All of them work fine, except one that has a slightly different configuration.


It is located in a UserControl that includes one TabControl with two tabs. In the first tab there is a form with some other controls, in the second one there is the ScheduleView control that shows the same data from the form in the first tab.

The ScheduleView is configured with 4 boolean attached properties (called IsDay.., IsMonth... , IsWeek... and IsTimlineViewAllowed) that determine if the related ViewDefinition will be available in the ScheduleView. These attached properties are of course bound from properties in the view model.

The ScheduleView control has got no ViewDefinitions hardcoded in the XAML, because each ViewDefinition is dinamically created by the related change event handler of the attached property. Here you can see one of them (the one for the month, just to give an example), it does a really simple job:

private static void OnIsMonthViewAllowedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
    RadScheduleView scheduler = obj as RadScheduleView;
    bool allowed = Convert.ToBoolean(args.NewValue.ToString());
    ViewDefinitionBase monthView = null;

    if (allowed && scheduler != null)
    {
        monthView = new MonthViewDefinition() { StretchGroupHeaders = true };
        scheduler.ViewDefinitions.Add(monthView);
    }
}

This similar configuration works fine in all other ScheduleView controls of the product, but in this case the statement

scheduler.ViewDefinitions.Add(monthView);

 throws the exception exception "Cannot change ObservableCollection during a CollectionChanged or PropertyChanged event." when switching from the first to second tab.

I have a suspect that this is something related to the collection of appointments or something else, and in fact I did an "experiment" and if I try to :
  1. remove the appointments to the ScheduleView
  2. add the ViewDefinition to the ScheduleView
  3. re-populate the datasource of appointments

It does not throw the exception and the ScheduleView appears as expected with all its appointments.
However this is not the ideal approach as this is a very ugly design. Even if it is kinda working we eventually should need to re-configure in this way all the aspects of the ScheduleView (we use resource grouping, we use resource headers, we use a lot of things that really descourages the use of this experimental tecnique).

Do you know if there's a reason that is causing this behaviour? It would be great if you could suggest a way to avoid the problem, or even a tip to improve our design (meaning avoid using attached properties, or avoid adding ViewDefinitions at run-time in this way).

Thank you very much!

Kind Regards,

Massimiliano Giustizieri, Italy.

------------------------------------------------------------------------------------------
Edit: The behaviour is exactly as described in this other post http://www.telerik.com/community/forums/silverlight/scheduleview/scheduleview-in-radtabcontrol-throws-error-when-tab-re-activated.aspx, meaning that it happens only the second time the TabControl with the ScheuleView is activated.

4 Answers, 1 is accepted

Sort by
0
Massimiliano Giustizieri
Top achievements
Rank 1
answered on 15 Jun 2011, 12:08 PM
Alternatively, instead of creating and adding new views (which may be the action that directly or indirectly causes the problem), is there a way to customize the appearance of the ViewDefinitions buttons in the navigation bar ?

This would probably help, because the ViewDefinitions could be moved from the attached properties handlers back to the XAML, and then the ViewDefinitions filtering mechanism would be implemented simply by hiding and showing the selected views (since ViewDefinitions don't seem to have a Visibility property).

Thanks again!

Regards,

Massimiliano.
0
Accepted
Hristo
Telerik team
answered on 17 Jun 2011, 11:32 AM
Hello Massimiliano,

This error is caused by bug in the Silverlight Framework - we create CollectionView for the AppointmentsSource collection. Then when you switch to the first tab data context changed should be fired for the RadScheduleView and there we will remove handlers from this CollectionView. But the problem is that in SL we do not receive this event and cannot disconnect from the CollectionView. Then on second activation of RadTabItem which contains RadScheduleView it happened that a new instance of RadScheduleView is created and it tries to prepare the same CollectionView (group it) as the old RadScheduleView. This preparing raise CollectionView event that is also handled from the old ScheudleView which also tries to prepare the CollectionView and this cause an exception.
We have contacted Microsoft about this problem and we are waiting for solution.
Meanwhile you can set IsContentPreserved=True on RadTabControl to workaround the problem.

All the best,
Hristo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Xavier Lavigne
Top achievements
Rank 1
answered on 23 Aug 2012, 07:47 AM
Hi,

Any news about this bug ? We've got the same problem using RadScheduleView in Lightswitch and we don't have any access to the tab's properties.

Any workaround would also be appreciated.

Thanks by advance.
0
Vladi
Telerik team
answered on 28 Aug 2012, 11:28 AM
Hello Xavier,

There haven't been any fixes released concerning this issue in Silverlight 4 and we can not provide you with any appropriate workarounds.

There aren't any plans on implementing any work-arounds for this issue in the control because making those kind of changes are considered breaking changes and may lead to other unexpected issues.

We are sorry for any inconvenience that this may be causing.

Regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Massimiliano Giustizieri
Top achievements
Rank 1
Answers by
Massimiliano Giustizieri
Top achievements
Rank 1
Hristo
Telerik team
Xavier Lavigne
Top achievements
Rank 1
Vladi
Telerik team
Share this question
or