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

Removing RadPanes/PanelGroups/RadSplitContainers dynamically

5 Answers 333 Views
Docking
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nidhi
Top achievements
Rank 1
Nidhi asked on 27 Dec 2011, 08:38 AM

Hi Team,

 

We are using RadDock control in our application. We are adding Panes(RadPane->RadPaneGroup->RadSplitContainer) dynamically in dock control.

Now, we want to remove all panes including (RadPaneGroup/RadSplitContainer).

 

We write following code.

    foreach (RadSplitContainer item in mainDock.Items)

            {

                foreach (RadPaneGroup panel in item.Items)

                {

                    //Remove panes in a group

                    panel.Items.Clear();

                }

 

                //Remove group

                item.Items.Clear();

               

            }

 

            //To remove split containers

            mainDock.Items.Clear();

          

It is removing the all split containers/groups/panes . But again when we try to add any split container dynamically in dock control.

It’s giving us runtime error.

 

{MS.Internal.WrappedException: Error HRESULT E_FAIL has been returned from a call to a COM component. ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)

   at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)

   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)

   at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)

   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

   at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)

   at System.Windows.Controls.ItemsControl..ctor()

   at MS.Internal.CoreTypes.GetCoreWrapper(Int32 typeId)

   at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)

   at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)

   at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)

   at MS.Internal.XcpImports.Collection_GetItemDependencyObject[T](PresentationFrameworkCollection`1 collection, Int32 index)

   at System.Windows.PresentationFrameworkCollection`1.GetItemDependencyObject(Int32 index)

   at System.Windows.Controls.UIElementCollection.GetItemImplSkipMethodPack(Int32 index)

   at System.Windows.PresentationFrameworkCollection`1.CollectionEnum`1.get_Current()

   at System.Windows.PresentationFrameworkCollection`1.CollectionEnum`1.System.Collections.IEnumerator.get_Current()

   at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()

   at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)

   at Telerik.Windows.Controls.DockingPanel.MeasureOverride(Size availableSize)

   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)

   --- End of inner exception stack trace ---}

    [MS.Internal.WrappedException]: {MS.Internal.WrappedException: Error HRESULT E_FAIL has been returned from a call to a COM component. ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)

   at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)

   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)

   at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)

   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

   at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)

   at System.Windows.Controls.ItemsControl..ctor()

   at MS.Internal.CoreTypes.GetCoreWrapper(Int32 typeId)

   at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)

   at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)

   at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)

   at MS.Internal.XcpImports.Collection_GetItemDependencyObject[T](PresentationFrameworkCollection`1 collection, Int32 index)

   at System.Windows.PresentationFrameworkCollection`1.GetItemDependencyObject(Int32 index)

   at System.Windows.Controls.UIElementCollection.GetItemImplSkipMethodPack(Int32 index)

   at System.Windows.PresentationFrameworkCollection`1.CollectionEnum`1.get_Current()

   at System.Windows.PresentationFrameworkCollection`1.CollectionEnum`1.System.Collections.IEnumerator.get_Current()

   at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()

   at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)

   at Telerik.Windows.Controls.DockingPanel.MeasureOverride(Size availableSize)

   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)

   --- End of inner exception stack trace ---}

    Data: {System.Collections.ListDictionaryInternal}

    InnerException: {System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)

   at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)

   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)

   at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)

   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)

   at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)

   at System.Windows.Controls.ItemsControl..ctor()

   at MS.Internal.CoreTypes.GetCoreWrapper(Int32 typeId)

   at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)

   at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)

   at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)

   at MS.Internal.XcpImports.Collection_GetItemDependencyObject[T](PresentationFrameworkCollection`1 collection, Int32 index)

   at System.Windows.PresentationFrameworkCollection`1.GetItemDependencyObject(Int32 index)

   at System.Windows.Controls.UIElementCollection.GetItemImplSkipMethodPack(Int32 index)

   at System.Windows.PresentationFrameworkCollection`1.CollectionEnum`1.get_Current()

   at System.Windows.PresentationFrameworkCollection`1.CollectionEnum`1.System.Collections.IEnumerator.get_Current()

   at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()

   at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)

   at Telerik.Windows.Controls.DockingPanel.MeasureOverride(Size availableSize)

   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)}

    Message: "Error HRESULT E_FAIL has been returned from a call to a COM component."

    StackTrace: null

 

 

If I remove the following line from the code, Its not giving any error in adding another splitcontainer dynamically, having panes. But in that case, empty containers remain in the items collection.

//To remove split containers

 mainDock.Items.Clear();

 

Please see above code and check this is a correct way to remove/ clear panes & parents(RadPanelGroup/RadSplitConatiner) docking control. We have set HasDocumentHost="False" property

of docking control.

 Regards,

Nidhi

5 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 30 Dec 2011, 10:58 AM
Hello,

I am not able to reproduce the bad behavior at my side. I have attached the project I used, please take a look and tell me if you are doing something different in order for this error to appear.

Kind regards,
Boyan
the Telerik team

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

0
Simon Störmer
Top achievements
Rank 1
answered on 15 Oct 2012, 07:13 AM
Thanks for this example but it doesn´t work if the new dynamically generated rad panes are floating.

I have 2 Problems.

1. I like to save the layout of the current docking windows without the dynamic generated rad panes.
2. For this I would remove all the dynamic generated rad panes from the group befor we saved the layout.

I can´t find any solution for one of my problems. Do you have any Idea?

Thanks
0
Boyan
Telerik team
answered on 18 Oct 2012, 09:03 AM
Hello Simon,

I tested the project with Floatihg generated Panes but it was working as expected on my side. Could you provide more info what exactly is the problem and which version of the controls you are using.

As for the two questions, what you can do is to save the layout to a XML as shown in this example and then remove from the XML all elements that have some Tag(you can use SerializationTag) that you have added. Note that this is not so elegant solution, but currently we don't have out of the box way to exclude some items from saving. There is a feature request for that and you can follow its progress in our PITS.

Kind regards,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mirko
Top achievements
Rank 1
answered on 22 Oct 2012, 02:31 PM
Thanks for your answer. It´s easy to reproduce the problem.

  1. Download the example 2 post before
  2. Use the Telerik Release 2012.1.326.1050
  3. Start the program
  4. Now press the "add items" button
  5. Take the header of the "Document 1" panel and take it with the mouse in the floating state.
  6. Now press the "remove items" button.

All items are removed without the floating panels.

I tried to remove the generated panels from the xml stream and then save the stream and load it later to the rad docking. I get everytime a exception in the loading function. 

Do you have a example for that?

Thanks
0
Boyan
Telerik team
answered on 25 Oct 2012, 10:59 AM
Hello Mirko,

I think the problem is that you are using mainDock.Items which only takes the its children, but the ToolWindows are not children of the RadDock, so in order to properly get them you should use SplitContainers collection. Your code should be changed like this:
void b_Click(object sender, RoutedEventArgs e)
{
    foreach (RadSplitContainer item in mainDock.SplitContainers)
    {
        for (int i = 0; i < item.Items.Count; i++)
        {
            var panel = (RadPaneGroup)item.Items[i];
            panel.Items.Clear();
        }
        //Remove group
        item.Items.Clear();
    }
    //To remove split containers
    mainDock.Items.Clear();
}
Note that I have changed the "foreach" with "for" cycle in order for this to work. This way the floating Panes would be removed as well.


All the best,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Docking
Asked by
Nidhi
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Simon Störmer
Top achievements
Rank 1
Mirko
Top achievements
Rank 1
Share this question
or