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
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, MattDeverloper Support Engineer
Thanks Matt,
Unfortunately I'm unable to get your code snippet to work. See attached example. I'm using version 11.2
Wire up the documentContentHost loaded event and move your code to that handler
<ig:DocumentContentHost Loaded="documentContentHost1_Loaded"
private void documentContentHost1_Loaded(object sender, RoutedEventArgs e) { ContentPane cp = this.xamDockManager1.FindPane("DataViewer") as ContentPane; MessageBox.Show(cp.Name);
TabGroupPane tgp = this.xamDockManager1.DocumentContentHost.Panes[0] as TabGroupPane; string s = string.Empty; foreach (ContentPane cp1 in tgp.Panes) { s += cp1.Name + " "; } MessageBox.Show(s); }
Sincerely, Matt Developer Support Engineer
HI,
Please let me know if you need further assistance.