Adding RadPane to RadPaneGroup Programatically

3 posts, 0 answers
  1. Ryan
    Ryan avatar
    1 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2009 Link to this post

    Hi Everyone,

    I need to be able to add a RadPane control to a RadPaneGroup Programatically. I am using the following code to add the new RadPane to a RadPaneGroup that is declared in XAML.

    PnlVehicleStatus = new RadPane 
        CanFloat = true
        CanDockInDocumentHost = false
        CanUserPin = true
        Title = "Vehicle Status"
        Header = "Vehicle Status"
        CanUserClose = true
        IsPinned = true
        Name = "PnlVehicleStatus"
        Tag = "Test" 
    PnlVehicleStatus.Content = new GeoHostVehicleStatus(); 
    AddWindowToToggle(PnlVehicleStatus, (string)PnlVehicleStatus.Header); 
    RSCDockRight.AddItem(PnlVehicleStatus, DockPosition.Right); 

    <RadDock:RadDocking x:Name="Docking" Grid.Row="2" LayoutUpdated="RadDocking_LayoutUpdated"
                    <RadDock:RadPaneGroup x:Name="RSCDockLeft"
                <RadDock:RadSplitContainer  InitialPosition="DockedRight"
                    <RadDock:RadPaneGroup x:Name="RSCDockRight"
                        <RadDock:RadPane x:Name="PnlMain" RadDock:RadDocking.SerializationTag="PnlMain"

    This code ends with an null reference exception being called on the additem call.

    Any help in figuring out why I am getting a null reference exception would be appreciated.

    Thank you in advance.

  2. Miroslav Nedyalkov
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 23 Oct 2009 Link to this post

    Hi Ryan,

    What I suspect is that you are trying to add the pane at the right side of a pane group that is not added in a SplitContainer yet and this is not possible, because it cannot detect in which SplitContainer the new pane should be added. Only adding to the center of a pane group is allowed before the group is placed in a SplitContainer.

    As I don't know what the goal is - to add the newly created pane next to the group or in it, I cannot give a concrete advise what to do. Because of the title of the thread I assume you need to add the pane in the group, so you just need to change the last line of code to RSCDockRight.AddItem(PnlVehicleStatus, DockPosition.Center);
    Hope this helps.

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft R3 2016 release webinar banner
  4. Radhakrishnan
    Radhakrishnan avatar
    2 posts
    Member since:
    Sep 2012

    Posted 26 Sep 2012 Link to this post

    Can somebody show How to programmatically create a RadPaneGroup and attach a it to a dynamically created RadSplitContainer?!!Regards
Back to Top