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

RadPane as UserControl error "Undock"

3 Answers 61 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Sébastien Chicoine
Top achievements
Rank 1
Sébastien Chicoine asked on 14 Dec 2010, 06:11 PM
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

3 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 16 Dec 2010, 03:38 PM
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
0
Sébastien Chicoine
Top achievements
Rank 1
answered on 16 Dec 2010, 04:10 PM
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
0
Accepted
Konstantina
Telerik team
answered on 17 Dec 2010, 10:24 AM
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
Tags
Docking
Asked by
Sébastien Chicoine
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Sébastien Chicoine
Top achievements
Rank 1
Share this question
or