RadPane as UserControl error "Undock"

4 posts, 1 answers
  1. Sébastien Chicoine
    Sébastien Chicoine avatar
    6 posts
    Member since:
    May 2010

    Posted 14 Dec 2010 Link to this post

    Hi,

        I created a Silverlight User Control of type RadPane.

        In the constructor of the MainPage, I've added this control into a RadGroupPanel many times.  When i'm trying to "undock" one of the RadPane, an exception is thrown saying that the LayoutRoot already exist.

        RadPaneTest :
    <telerik:RadPane x:Class="PbDocking.RadPaneTest"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"         
        mc:Ignorable="d" Header="RadPaneTest">
          
      <telerik:RadPane.Content>
        <Grid x:Name="LayoutRoot" Background="White">
          <TextBlock x:Name="TxtText" Text="Message !!"  HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
        </Grid>
      </telerik:RadPane.Content>
    </telerik:RadPane>

    MainPage.xaml.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Controls.Docking;
      
    namespace PbDocking
    {
      public partial class MainPage : UserControl
      {
        RadDocking radDocking;
        DocumentHost documentHost;
        RadSplitContainer radSplitContainer; 
        RadPaneGroup radPaneGroup;
      
        public MainPage()
        {
          radDocking = new RadDocking();
          documentHost = new DocumentHost();
          radSplitContainer = new RadSplitContainer();
          radPaneGroup = new RadPaneGroup();
      
          for (int i = 0; i < 10; ++i)
          {
            RadPaneTest rpt = new RadPaneTest();
            rpt.TxtText.Text = "Message " + i.ToString() + " !";
            radPaneGroup.AddItem(rpt, DockPosition.Center);
          }
      
          radSplitContainer.Items.Add(radPaneGroup);
          documentHost.AddSplitItem(radSplitContainer);
          radDocking.DocumentHost = documentHost;
      
          this.Content = radDocking;
            
        }
      }
    }



        Can you tell me what i'm doing wrong ?

    Thanks.

    Sébastien Chicoine
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 16 Dec 2010 Link to this post

    Hello Sébastien,

    Thank you for the code snippets, they helped a lot.

    The problem is in the x:Name-s of the Grid and the TextBox. The RadPane does not create its own namescope like the UserControl and that is causing the error. If you remove the x:Name of the Grid and TextBox it will work as expected.

    Hope this information helps. Please let us know if you have any other questions.

    Regards,
    Konstantina
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Sébastien Chicoine
    Sébastien Chicoine avatar
    6 posts
    Member since:
    May 2010

    Posted 16 Dec 2010 Link to this post

    Hello,

        So, if I want to reach my control's childrens from an other class, the best solution is to create them programmatically and avoid the use of x:name ?

    Sébastien Chicoine
  5. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 17 Dec 2010 Link to this post

    Hi Sébastien,

    Yes, that is correct. Since the RadPane doesn't create its own namescope this is the best solution.

    All the best,
    Konstantina
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top