Dynamic PanelBar Datasource

2 posts, 0 answers
  1. Doug
    Doug avatar
    13 posts
    Member since:
    Apr 2014

    Posted 26 May 2014 Link to this post

    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!

  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1251 posts

    Posted 29 May 2014 Link to this post

    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.

    Pavel R. Pavlov
    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.
Back to Top