Problem with RadPane.RemoveFromParent()

6 posts, 0 answers
  1. C Bates
    C Bates avatar
    33 posts
    Member since:
    Oct 2009

    Posted 09 Jan 2010 Link to this post

    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.



  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 11 Jan 2010 Link to this post

    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.
  3. C Bates
    C Bates avatar
    33 posts
    Member since:
    Oct 2009

    Posted 11 Jan 2010 Link to this post

    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.

  4. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 11 Jan 2010 Link to this post

    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.
  5. C Bates
    C Bates avatar
    33 posts
    Member since:
    Oct 2009

    Posted 12 Jan 2010 Link to this post

    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.

  6. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 13 Jan 2010 Link to this post

    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.
Back to Top