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

Programmatic Adding RadPane to DocumentHost

1 Answer 260 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 07 Nov 2012, 09:29 PM
Hi,

I have a dockinghost and a separate split container docked ot the right. I am trying to programmatically add panes and documentpanes with a user control. When I try to add a pane or document pane to the panegroup in the documenthost, I get an error:

NullReferenceException was unhandled by user code
Object reference not set to an instance of an object.

XAML and codebehind are below, any ideas why I get the error? 

<telerik:RadDocking x:Name="ctlDocking">
 <telerik:RadDocking.DocumentHost>
  <telerik:RadSplitContainer>
   <telerik:RadPaneGroup x:Name="TopPaneGroup">
   </telerik:RadPaneGroup>
  </telerik:RadSplitContainer>
 </telerik:RadDocking.DocumentHost>
 <telerik:RadSplitContainer Orientation="Vertical" InitialPosition="DockedRight">
  <telerik:RadPaneGroup x:Name="RightPaneGroup">
  </telerik:RadPaneGroup>
 </telerik:RadSplitContainer>
</telerik:RadDocking>

 public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            // this line works
            AddPane("Issues", new UserControl(), "RightPaneGroup", DockPosition.Top);
            // this line doesnt
            AddDocumentPane("Issues", new UserControl(), "TopPaneGroup", DockPosition.Top);
        }

        private object FindPaneByTitle(string title)
        {
            return new object();
        }

           
        private RadPane AddPane(string title, UserControl control, string paneGroup, DockPosition position)
        {
           
            RadPaneGroup group = FindName(paneGroup) as RadPaneGroup;
            RadPane r=null;

            if (group != null)
            {
                r = new RadPane();
                r.Title = title;
                r.Content = control;
                r.CanDockInDocumentHost = true;
                group.AddItem(r, position);
            }
           
            return r;
        }

        private RadDocumentPane AddDocumentPane(string title, UserControl control, string paneGroup, DockPosition position)
        {
            RadPaneGroup group = FindName(paneGroup) as RadPaneGroup;
            RadDocumentPane r=null;

            if (group != null)
            {
                r = new RadDocumentPane();
                r.Title = title;
                r.Content = control;
                r.CanDockInDocumentHost = true;
                 group.AddItem(r, position);               
            }

            return r;
        }
 }


1 Answer, 1 is accepted

Sort by
0
Rick
Top achievements
Rank 1
answered on 08 Nov 2012, 05:03 PM
Hi,

Figured it out

The code works if I use DockPosition.Center

Rick
Tags
Docking
Asked by
Rick
Top achievements
Rank 1
Answers by
Rick
Top achievements
Rank 1
Share this question
or