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

Access control on main page?

1 Answer 166 Views
Navigation
This is a migrated thread and some comments may be shown as answers.
Serrin
Top achievements
Rank 1
Serrin asked on 09 Jan 2009, 05:24 PM
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.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 09 Jan 2009, 07:26 PM
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; 
Tags
Navigation
Asked by
Serrin
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Share this question
or