Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
855
DocumentContentHost: Accessing Panes from Code-Behind
posted

I'm trying to get access to panes contained in the documentcontenthost. In my xamDockManager_Load event I have this line:

ContentPane pane1 = (this.xamDockManager.DocumentContentHost.Panes[0] as TabGroupPane).Panes[0] as ContentPane;

// do something with pane1

The line above gives me a null reference exception.

Please assist.

Thanks

Parents
No Data
Reply
  • 28407
    posted

    HI ,

    You can use the XamDockManager's FindName method and pass the name of the pane to it.

    or

     If you DocumentContentHost has a TabGroupPane then the code would look as follows.
    ContentPane cp =
                 xamDockManager1.FindName("cp1") as ContentPane;

                MessageBox.Show(cp.Name);
                TabGroupPane tgp = xamDockManager1.DocumentContentHost.Panes[0] as TabGroupPane;
                string s = string.Empty;
                foreach (ContentPane cp1 in tgp.Panes)
                {
                    s += cp1.Name + " ";
                }
                MessageBox.Show(s);

     Sincerely,
     Matt
    Deverloper Support Engineer

     

     

     

     

Children