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

Is there a way to stop RadPanelBar from resetting when rebinding to datasource?

1 Answer 53 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 03 Nov 2009, 04:22 PM
When the ItemsSource property is set by a background task (periodic timer), the RadPanelBar resets, i.e. the panels collapse and the selected item highlight disappears.

I have implemented a cache to save the state of the RadPanelBar and RadPanelBarItems so that it can be restored to its original state, after the ItemsSource property has been set. However this is causing a horrible flicker.

Is there a way to maintain the state of the RadPanelBar after the ItemsSource property has been set without having to do manually?

Would binding to an ObservableCollection instead make any difference?
(admittedly perhaps I should have done this in the first place, but didn't know about it until recently).

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Tihomir Petkov
Telerik team
answered on 04 Nov 2009, 09:47 AM
Hello Ryan,

What you observed while changing the ItemsSource property is the expected behavior. In fact, all ItemsControls behave in the same way. When you set (or reset) the ItemsSource property, what happens behind the scenes is that RadPanelBarItem objects are created on the fly and used to wrap your business objects. So, when you change the ItemsSource, the visual elements are destroyed and new ones a created for your new data source.

In case you need to update only certain items in your source and/or you want to avoid the re-generation of the visual items you should use an ObservableCollection for your data source. If you have a hierarchy of objects, you will need to make their items collections ObservableCollections as well. This way any changes in your source collection will be reflected in the layout of your application without rebuilding the entire tree of visual elements that comprise your PanelBar.

I hope I was able to help. Please let me know if you have any other questions.

Regards,
Tihomir Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
PanelBar
Asked by
Ryan
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Share this question
or