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

Dynamic PanelBar Datasource

1 Answer 78 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 26 May 2014, 10:38 PM
Hello, everyone.

I am working on an MVVM / Prism application and I have run into a bit of  a snag on how to populate my PanelBar with items.  For reference: I am trying to create a layout similar to the one found here. On the referenced page assume that Products and Support are each their own separate modules, and that each item under them represents a view within that module. Now assume that there is security built around both Modules and Views so that only certain people can see them.  

I am already dynamically loading my modules via reflection, but I am at a loss on how to do dynamically load my views.  To register my views, I would typically do something like this:

RegionManager.Regions["NavRegion"].Add(Container.Resolve<DefaultView>(), "TheDefaultView");

Where "NavRegion" is a custom region that I have a RegionAdapter for.  The problem is that I don't see a way to setup my RegionAdapter to get my PanelBar to display in the manner I would like since I can't really build a Hierarchical structure in my RegionAdapter. Is there anyway that I could bind to an XML document that defines the structure of the items?  If there is a way to do that, is it possible to append to a bound xml datasource? What I mean is: Module1 has an XML document that defines what views to show, Module2 has an XML document that defines what views to show, and so on.

Thanks for any help you might be able to provide!

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 29 May 2014, 10:41 AM
Hello Doug,

There is no need to build hierarchy in the region adapter or using XML to build the structure. You can inject a view and a corresponding viewmodel into the region. You can inject RadPanelBarItems along with their DataContext. For your convenience I prepared a sample project demonstrating this approach.

Please take a look at it and let me know if it fits your scenario.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PanelBar
Asked by
Doug
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or