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

Switch layout when switching RadDocumentPane?

1 Answer 85 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Kristoffer
Top achievements
Rank 1
Kristoffer asked on 05 Dec 2012, 10:54 AM
I have some RadDocumentPanes. When I opening a document (RadDocumentPane) of some type, I want to load a different layout. How can this be done?

I tried switching layout in the ActivePaneChanged event, but this throws an InvalidOperationException. Please help!

private void dockingPaneManager_ActivePaneChanged(object sender,
    Telerik.Windows.Controls.Docking.ActivePangeChangedEventArgs e)

{

    if (e.NewPane == pane1)

        LoadLayout(Properties.Resources.Pane1);

    else if (e.NewPane == pane2)

         LoadLayout(Properties.Resources.Pane2);

    else if (e.NewPane == pane3)

         LoadLayout(Properties.Resources.Pane3);

}


<telerik:RadDocking x:Name="dockingPaneManager" ActivePaneChanged="dockingPaneManager_ActivePaneChanged">
<telerik:RadDocking.DocumentHost>
  <telerik:RadSplitContainer>
    <telerik:RadPaneGroup>
      <telerik:RadDocumentPane x:Name="pane1" Title="1st" telerik:RadDocking.SerializationTag="Pane1">
        <telerik:RadDocumentPane.Content>
          ... some content ...
        </telerik:RadDocumentPane.Content>
      </telerik:RadDocumentPane>
      <telerik:RadDocumentPane x:Name="pane2" Title="2nd" telerik:RadDocking.SerializationTag="Pane2">
        <telerik:RadDocumentPane.Content>
          ... some content ...
        </telerik:RadDocumentPane.Content>
      </telerik:RadDocumentPane>
      <telerik:RadDocumentPane x:Name="pane3" Title="3rd" telerik:RadDocking.SerializationTag="Pane3">
        <telerik:RadDocumentPane.Content>
          ... some content ...
        </telerik:RadDocumentPane.Content>
      </telerik:RadDocumentPane>
    </telerik:RadPaneGroup>
  </telerik:RadSplitContainer>
</telerik:RadDocking.DocumentHost>


This is the thrown exception:
---------------------------

---------------------------
System.InvalidOperationException: The specified Visual is not an ancestor of this Visual.

   at System.Windows.Media.Visual.TrySimpleTransformToAncestor(Visual ancestor, Boolean inverse, GeneralTransform& generalTransform, Matrix& simpleTransform)

   at System.Windows.Media.Visual.InternalTransformToAncestor(Visual ancestor, Boolean inverse)

   at Telerik.Windows.Controls.ApplicationHelper.TransformToScreenRoot(UIElement target) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Common\ApplicationHelper.cs:line 285

   at Telerik.Windows.Controls.RadPane.GetDraggableArea(Boolean allowDragReorder) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Docking\Docking\Docking\RadPane.cs:line 1378

   at Telerik.Windows.Controls.RadPane.OnHeaderMouseLeftButtonDown(Object sender, MouseButtonEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Docking\Docking\Docking\RadPane.cs:line 886

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)

   at System.Windows.Input.InputManager.ProcessStagingArea()

   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)

   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)

   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
---------------------------
OK  
---------------------------

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 10 Dec 2012, 10:12 AM
Hi Kristoffer,

We are not sure what exactly you are trying to achieve but changing the content of a Pane in the ActivePaneChanged is not a good approach. The content of a RadPane should be set when you first load the control or when you load the layout of the control. If you want to change the content of a Pane it is better to remove that Pane and add a new one with the new content.

Hope this is helpful.

If you have any other questions on this case could you send us a runnable project so we can observe the exact scenario you are trying to achieve?

All the best,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Docking
Asked by
Kristoffer
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Share this question
or