Programmatic Adding RadPane to DocumentHost

2 posts, 0 answers
  1. Rick Hodder
    Rick Hodder avatar
    17 posts
    Member since:
    Jul 2004

    Posted 07 Nov 2012 Link to this post

    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;
            }
     }


  2. Rick Hodder
    Rick Hodder avatar
    17 posts
    Member since:
    Jul 2004

    Posted 08 Nov 2012 Link to this post

    Hi,

    Figured it out

    The code works if I use DockPosition.Center

    Rick
  3. DevCraft banner
Back to Top