Error with Docking structure

Posted by: abellisomi on 20 August 2020, 1:04 am EST

    • Post Options:
    • Link

    Posted 20 August 2020, 1:04 am EST

    I am trying to have two tabs [A,B] that contain a sliding tab [A1, B1] and a main tab with content [A2, B2] each.

    
        <c1:C1DockControl>
            <c1:C1DockTabControl >
                <c1:C1DockTabItem Header="A" >
                    <c1:C1DockTabControl DockMode="Docked">
                        <c1:C1DockTabControl DockMode="Sliding">
                            <c1:C1DockTabItem  Header="A1">
                                <TextBlock Text="A1" />
                            </c1:C1DockTabItem>
                        </c1:C1DockTabControl>
                        <c1:C1DockTabControl DockMode="Docked">
                            <c1:C1DockTabItem  Header="A2">
                                <TextBlock Text="A2" />
                            </c1:C1DockTabItem>
                        </c1:C1DockTabControl>
                    </c1:C1DockTabControl>
                </c1:C1DockTabItem>
                <c1:C1DockTabItem Header="B" >
                    <c1:C1DockTabControl DockMode="Docked">
                        <c1:C1DockTabControl DockMode="Sliding">
                            <c1:C1DockTabItem  Header="B1">
                                <TextBlock Text="B1" />
                            </c1:C1DockTabItem>
                        </c1:C1DockTabControl>
                        <c1:C1DockTabControl DockMode="Docked">
                            <c1:C1DockTabItem  Header="B2">
                                <TextBlock Text="B2" />
                            </c1:C1DockTabItem>
                        </c1:C1DockTabControl>
                    </c1:C1DockTabControl>
                </c1:C1DockTabItem>
            </c1:C1DockTabControl>
        </c1:C1DockControl>
    
    

    A and B are mutually exclusive, as I want the users to be able to flip between their content and see A [A1 slide, A2 dock] or B [B1 slide, B2 dock].

    Every time I load this structure though the component breaks with this error:

    
    Stack Trace: System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
       at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
       at System.Windows.FrameworkElement.AddLogicalChild(Object child)
       at C1.WPF.C1TabItem.<>c.<.cctor>b__15_0(DependencyObject s, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at C1.WPF.C1TabItem.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at C1.WPF.C1TabControl.PrepareContainerForItemOverride(DependencyObject element, Object item)
       at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
       at System.Windows.Controls.Panel.GenerateChildren()
       at System.Windows.Controls.Panel.EnsureGenerator()
       at System.Windows.Controls.Panel.get_InternalChildren()
       at C1.WPF.C1TabControl.UpdateVisualState()
       at C1.WPF.C1TabControl.OnAfterApplyTemplate()
       at C1.WPF.C1TabControl.OnApplyTemplate()
       at C1.WPF.Docking.C1DockTabControl.OnApplyTemplate()
       at System.Windows.FrameworkElement.ApplyTemplate()
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at C1.WPF.C1LinePanel.MeasureOverride(Size availableSize)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at C1.WPF.Docking.C1DockControlPanel.MeasureOverride(Size availableSize)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    Exception thrown: 'System.ArgumentOutOfRangeException' in PresentationFramework.dll
    Specified argument was out of the range of valid values.
    
    

    Any idea on how to fix this or how can I achieve the requirements?

    Thank you

  • Posted 20 August 2020, 1:05 am EST

    I am using v4.5.20202.716 of the component.

  • Posted 21 August 2020, 6:44 am EST

    Hi,

    As I understand, you want to operate with C1DockControl in a way that at any point in time, there is only one pair of sliding and docked tab (A1 & A2 or B1 and B2).

    If so, you would need to use code-behind as well. For reference, I have attached an application wherein as you select a sliding tab, only the corresponding docked tab remains visible.

    You can modify the application as per your requirement.

    Thanks,

    DockingStructure_WPF.zip

  • Posted 24 August 2020, 7:23 am EST

    Thanks a lot, your example put me on the right track to conclude with a more MVVM approach, see the following:

    
            <c1:C1DockControl>
                <c1:C1DockGroup>
                    <c1:C1DockTabControl x:Name="slidingTab" DockMode="Sliding">
                        <c1:C1DockTabItem x:Name="itemA1" Header="A1" IsSelected="{Binding Model.IsATabVisible, Mode=TwoWay}">
                            <TextBlock Text="A1" Background="DarkGray"/>
                        </c1:C1DockTabItem>
                        <c1:C1DockTabItem x:Name="itemB1" Header="B1" IsSelected="{Binding Model.IsBTabVisible, Mode=TwoWay}">
                            <TextBlock Text="B1" Background="Turquoise"/>
                        </c1:C1DockTabItem>
                    </c1:C1DockTabControl>
                    <c1:C1DockTabControl x:Name="dockedTab" DockMode="Docked" TabStripPlacement="Top" CanUserSlide="False" CanUserFloat="False" CanUserHide="False" ShowHeader="False" CanUserDock="False">
                        <c1:C1DockTabItem Header="A2" Visibility="{Binding Model.IsATabVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <TextBlock Text="A2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextAlignment="Center" Background="DarkGray"/>
                        </c1:C1DockTabItem>
                        <c1:C1DockTabItem Header="B2" Visibility="{Binding Model.IsBTabVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <TextBlock Text="B2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextAlignment="Center" Background="Turquoise"/>
                        </c1:C1DockTabItem>
                    </c1:C1DockTabControl>
                </c1:C1DockGroup>
            </c1:C1DockControl>
    
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels