Access control on main page?

2 posts, 0 answers
  1. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 09 Jan 2009 Link to this post

    Hello Telerik!

    So my current setup is an app which has a nested RadFrameContainer, which works like a charm (result!).  What I am currently trying to do is access a RadPanelBar on the main page from a RadPage that has been loaded into the RadFrame in the container.  Now, normally for any usercontrol that was loaded in my old, custom navigation framework, I could do...

    // RadPanelPar's x:Name="rpbPanelBar" 
    Page p = (Page)Application.Current.RootVisual as Page;  
    p.rpbPanelBar.Whatever = new Whatever(); 

    Which used to work well and good, but now I'm running into an issue accessing rpbPanelBar.  Now, per the documentation my App.cs Application_Startup looks like this:

            private void Application_Startup(object sender, StartupEventArgs e)  
                this.RootVisual = new RadFrameContainer();  
                NavigationService service = NavigationService.GetNavigationService();  
                service.Target = this.RootVisual as RadFrameContainer;  
                service.Transition = new FadeTransition();  
                service.Navigate(new Page());  

    With Page containing a Grid with other controls as well as a RadFrameContainer (which contains a RadFrame, which is where navigation happens).  Trying to figure out how to access the rpbPanelBar, I came up with the following...

    RadFrameContainer p = (RadFrameContainer)Application.Current.RootVisual as RadFrameContainer;  
    Page r = (Page)p.Parent as Page;  
    r.rpbiAccount.Visibility = Visibility.Visible; 

    But while I can see in intellisense that r contains rpbiAccount, at runtime r comes up as null.  I tried switching RadPage for Page, but that also doesn't work.

    More or less, I need to know what to do in order to access the original RadPage Page() that is the main page of my application. :)

    Let me know if this is more of a support ticket issue and I'll happily submit my project, just figured there was an off chance that I was missing something simple that other people could use as well.

  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 09 Jan 2009 Link to this post

    After an hour of hammering away at this and trying everything under the sun, I have my answer (at long last!).

    So, for anyone else with a similar scenario...

    My page setup is as follows:

    RadPage         (my main page class)
    --Grid               (the layout mechanism for my page)
    ----RadFrameContainer    (container for the subpage that navigates)
    ------RadFrame                 (frame that changes)

    So after much trial and error, we now have...

    // get the navigation service, like we did in App.cs  
    NavigationService ourNav = NavigationService.GetNavigationService();  
    // ourNav.Target is a RadFrameContainer on the page, so it's parent is the  
    //   main layout grid  
    Grid layoutGrid = ourNav.Target.Parent as Grid;  
    // then the grid resides in the parent Page  
    Page rp = layoutGrid.Parent as Page;  
    // and the PanelBar is located on the Page.  Brilliant! :D  
    rp.rpbiAccount.Visibility = Visibility.Visible; 
Back to Top