How can I close all panes in a group

3 posts, 0 answers
  1. Steve
    Steve avatar
    124 posts
    Member since:
    Jun 2011

    Posted 25 Jun 2012 Link to this post

    I posted a thread two days ago about a problem I was having with e.Handled in a RadDocking.Close event.  After looking at the code, I moved the logic to the PreviewClose event; however the result is the same.  I am attempting to close all the panes in a RadPaneGroup inside the DocumentHost.   I have tried...
    • RadPaneGroup.HideAllPanes(), but the panes remain visible.  After the call I can close all but the first pane indiviually using the close button on each tab.  If I drag the last remaining pane off the tabstrip it disappears.
    • Any direct manipulation of the RadPaneGroup.Items, whether a call to Clear(), Remove(pane), RemoveAt(index) causes an n "Object reference not set to an instance of an object." exception after exiting the handler with e.Handled set to true.
      • at Telerik.Windows.Controls.RadPane.Close() in c:\TB\105WPF_Scrum\Current_HotFix\Sources\Controls\Docking\Docking\Docking\RadPane.cs:line 1360
           at Telerik.Windows.Controls.RadPane.OnIsHiddenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Docking\Docking\Docking\RadPane.cs:line 1186
    • I tried looping through the Items and using RemoveFromParent() but that causes an "Object reference not set to an instance of an object." exception when attempting to remove the second pane.
      • at Telerik.Windows.Controls.Primitives.TabStripPanel.<>c__DisplayClass14.<MeasureOverride>b__7(UIElement item) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Navigation\TabControl\TabStripPanel.cs:line 176
        at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
        at System.Linq.Enumerable.Max(IEnumerable`1 source)
        at Telerik.Windows.Controls.Primitives.TabStripPanel.<>c__DisplayClass14.<MeasureOverride>b__6(Double total, List`1 next) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Navigation\TabControl\TabStripPanel.cs:line 174
        at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
        at Telerik.Windows.Controls.Primitives.TabStripPanel.MeasureOverride(Size availableSize) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Navigation\TabControl\TabStripPanel.cs:line 171
        at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
        at System.Windows.UIElement.Measure(Size availableSize)
        at System.Windows.ContextLayoutManager.UpdateLayout()
        at Telerik.Windows.Controls.RadPane.OnDocumentHostTemplateChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Docking\Docking\Docking\RadPane.cs:line 1223
    • I tried removing all but the pane passed in the event args and leaving e.Handle false, hoping Close would take care of it, but that causes an "Object reference not set to an instance of an object." exception like the previous example.
      •    at Telerik.Windows.Controls.Primitives.TabStripPanel.<>c__DisplayClass14.<MeasureOverride>b__7(UIElement item) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Navigation\TabControl\TabStripPanel.cs:line 176
           at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
           at System.Linq.Enumerable.Max(IEnumerable`1 source)
           at Telerik.Windows.Controls.Primitives.TabStripPanel.<>c__DisplayClass14.<MeasureOverride>b__6(Double total, List`1 next) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Navigation\TabControl\TabStripPanel.cs:line 174
           at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
           at Telerik.Windows.Controls.Primitives.TabStripPanel.MeasureOverride(Size availableSize) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Navigation\TabControl\TabStripPanel.cs:line 171
           at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
           at System.Windows.UIElement.Measure(Size availableSize)
           at System.Windows.ContextLayoutManager.UpdateLayout()
           at Telerik.Windows.Controls.RadPane.OnDocumentHostTemplateChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) in c:\TB\105\WPF_Scrum\Current_HotFix\Sources\Controls\Docking\Docking\Docking\RadPane.cs:line 1223

    All of this happens in 2012.2.620 and did not happen in 2012.2.607.  Please let me know if there is a way to achieve this functionality without having to revert to using the previous version.

    Thanks in advance, Steve

  2. Georgi
    Admin
    Georgi avatar
    347 posts

    Posted 28 Jun 2012 Link to this post

    Hi Steve,

    You cant try using Dispatcher :
    RadPane pane = e.Panes.ToList()[0];
               RadPaneGroup group = pane.PaneGroup;
               if (closeall)
               {
                   Dispatcher.BeginInvoke(new Action(
                       () =>
                       {
                           group.HideAllPanes();
                           //group.Items.Clear();
     
                       }));
                   e.Handled = true;
               }

    It seems like this fixes the issue in my test project. It would be great if you can see if this works for you.
    Nevertheless the "Object reference not set to an instance of an object." exception should be fixed in the next LIB.
    Hope this will help.

    All the best,
    Georgi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Charles
    Charles avatar
    10 posts
    Member since:
    Dec 2011

    Posted 04 Apr 2014 in reply to Georgi Link to this post

                    <telerik:RadDocking.DocumentHost>
                        <telerik:RadSplitContainer BorderThickness="0" BorderBrush="WhiteSmoke" x:Name="radSplitContainer1">
                            <telerik:RadPaneGroup x:Name="radPaneGroup" BorderThickness="0" BorderBrush="WhiteSmoke" >
                                <telerik:RadDocumentPane x:Name="radane1" Header="Document 1">
                                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                                </telerik:RadDocumentPane>
                                <telerik:RadDocumentPane x:Name="radane2" Header="Document 2">
                                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                                </telerik:RadDocumentPane>
                                <telerik:RadDocumentPane x:Name="radane3" Header="Document 3">
                                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                                </telerik:RadDocumentPane>
                            </telerik:RadPaneGroup>
                        </telerik:RadSplitContainer>
                    </telerik:RadDocking.DocumentHost> 


     if (radPaneGroup.Items.Count > 0)  // closes only the documentpane
                {
                    //mainDock.ActivePane.IsHidden = true; //closes the 
                    radPaneGroup.SelectedPane.IsHidden = true;
                }
                else
                {
                    mainDock.ActivePane.IsHidden = false;
                }











Back to Top