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

Problem with RadPane.RemoveFromParent()

5 Answers 209 Views
Docking
This is a migrated thread and some comments may be shown as answers.
C Bates
Top achievements
Rank 1
C Bates asked on 09 Jan 2010, 06:28 PM
Hello,
Q3 release.
I have an application with 2 RadPaneGroups.  I add RadPanes to the first group.  I want to programmatically move a pane from one group to the other.

XAML:
            <docking:RadDocking x:Name="Docking" Grid.Row="1" > 
                <docking:RadSplitContainer x:Name="dockLeft" > 
                    <docking:RadPaneGroup x:Name="toolsGroup" > 
                    </docking:RadPaneGroup> 
                    <docking:RadPaneGroup x:Name="debugGroup" 
                    </docking:RadPaneGroup> 
                </docking:RadSplitContainer> 
                <docking:RadDocking.DocumentHost> 
                    <docking:RadSplitContainer x:Name="splitContainer1"
                        <docking:RadPaneGroup x:Name="mapGroup" > 
                        </docking:RadPaneGroup> 
                        <docking:RadPaneGroup x:Name="rightMapGroup"
                        </docking:RadPaneGroup> 
                    </docking:RadSplitContainer> 
                </docking:RadDocking.DocumentHost> 
            </docking:RadDocking> 
 

Create and add pane to RadPaneGroup:
            RadPane newPane = new RadPane(); 
            newPane.Header = new TextBlock() { 
                Text = mapName 
            }; 
 
            newPane.CanFloat = false
            newPane.CanDockInDocumentHost = false
            newPane.CanUserClose = false
            newPane.Tag = index; 
 
            ScrollViewer sv = new ScrollViewer(); 
            sv.VerticalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Disabled; 
            sv.HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Disabled;  
            sv.Content = LayoutRoot; // Grid control
            newPane.Content = sv; 
 
            newPane.MouseLeftButtonDown += new MouseButtonEventHandler(newPane_MouseLeftButtonDown); 
            newPane.MouseLeftButtonUp += new MouseButtonEventHandler(newPane_MouseLeftButtonUp); 
            newPane.GotFocus += new RoutedEventHandler(newPane_GotFocus); 
            // newPane.LostFocus += new RoutedEventHandler(newPane_LostFocus); 
            newPane.MouseEnter += new MouseEventHandler(newPane_MouseEnter); 
 
            this.mapGroup.Items.Add(newPane); 
 


Try to remove a pane:
                RadPane pane = mapGroup.SelectedPane; 
                if (null != pane) 
                { 
                    pane.RemoveFromParent(); 
                    rightMapGroup.Items.Add(pane); 
                } 
pane.RemoveFromParent() crashes with
"A first chance exception of type:
System.Windows.Markup.XamlParseException occurred in 
System.Windows.dll
Additional information: AG_E_UNKOWN_ERROR [line 2 position 309]"

I get the same result with
   mapGroup.RemovePane(pane);

What am I doing wrong?
Thanks for the help.



5 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 11 Jan 2010, 09:38 AM
Hello C Bates,

 As I don't know when you try to remove the pane from its parent I cannot say why it crashes. I guess you are trying to remove the selected pane from its parent when the selection is changed and this is not allowed. If this is the case I would suggest you to use Dispatcher to postpone the removal of the Pane from its parent. Here is an example:

mapGroup.Dispatcher.BeginInvoke( () =>
{
      RadPane pane = mapGroup.SelectedPane;
      if (null != pane)
      {
            pane.RemoveFromParent();
            rightMapGroup.Items.Add(pane);
      }
});

Greetings,
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.
0
C Bates
Top achievements
Rank 1
answered on 11 Jan 2010, 12:52 PM
Thanks for the reply; I'll try your suggestion.
We are not trying to move the pane in response to a selection changed event.
In my use case, we have two pane groups; the user can work in either group.  Each group can have more than one pane.
The user can click a button to move a pane in the right group to the left, or a pane in the left group to the right.

0
Miroslav Nedyalkov
Telerik team
answered on 11 Jan 2010, 02:12 PM
Hello C Bates,

 Please, try the work-around and if it diesn't fix the problem, please send us a sample project and we will investigate what the problem is and give you a better fix.

All the best,
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.
0
C Bates
Top achievements
Rank 1
answered on 12 Jan 2010, 08:09 PM
I suspect, although I haven't investigated yet, that the problem is that there is a SelectionChanged handler on the RadPaneGroup.
In my experience with the RadTabControl, I had to detach the RadTabControl.SelectionChanged handler before removing a RadTabItem programatically, then re-attaching the SelectionChanged handler.

0
Miroslav Nedyalkov
Telerik team
answered on 13 Jan 2010, 12:16 PM
Hi C Bates,

 Unfortunately I can only help if you send a sample project that reproduces the problem. Without such project we are shooting in the dark.

Sincerely yours,
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.
Tags
Docking
Asked by
C Bates
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
C Bates
Top achievements
Rank 1
Share this question
or