Problem with C1DockGroup and MVVM

Posted by: vinothkumar.r2210 on 7 October 2020, 1:24 pm EST

    • Post Options:
    • Link

    Posted 7 October 2020, 1:24 pm EST

    Hi,

    I’m working with C1DockGroup and MVVM. My problem is when I bind the itemssource, item’s not be added in C1DockGroup and throws invalid child error. Please do the needful and please refer my below xaml code.

    <c1:C1DockControl x:Name=“dockControl” Grid.Row=“2” ItemDockModeChanged=“DockControl_ItemDockModeChanged” PickerLoading=“DockControl_PickerLoading”>

    <c1:C1DockGroup Name=“dockGroup” ItemsSource=“{Binding DockGroupItems,UpdateSourceTrigger=PropertyChanged}”>

    c1:C1DockGroup.ItemTemplate



    c1:C1DockTabControl

    <c1:C1DockTabItem Header=“{Binding Department}”></c1:C1DockTabItem>

    </c1:C1DockTabControl>



    </c1:C1DockGroup.ItemTemplate>

    </c1:C1DockGroup>

    </c1:C1DockControl>

    public ObservableCollection DockGroupItems = new ObservableCollection();

    Thanks and Regards,

    Vinoth Kumar Ravi

  • Posted 7 October 2020, 10:03 pm EST

    Hi Vinoth,

    We are sorry to inform you that C1DockGroup and C1DockControl doesn’t support ItemsSource binding. This is because they act as containers(for DockTabControls) and uses ItemsControl.Items to handle docking/undocking. Since it’s not possible to use ItemsControl.ItemsSource along with ItemsControl.Items as per the WPF specification for ItemsControl and hence the behavior.

    Therefore, if needed to add items dynamically, we have to manually add C1DockTabControl’s to their Items property from code behind as follows:

    
    dockControl.Items.Add(new C1DockTabControl());
    Or
    dockGroup.Items.add(new C1DockTabControl());
    
    

    Regards,

    Kartik

  • Posted 8 October 2020, 3:49 pm EST

    Hi Kartik,

    Thanks for the reply. Is there any possibilities to support MVVM for C1DockGroup itemssource in future releases.

    Thanks and Regards,

    Vinoth Kumar Ravi

  • Posted 8 October 2020, 6:01 pm EST

    Hi Vinoth,

    We are really sorry for the inconvenience but it is the design limitation of the C1DockControl.

    As we discussed earlier C1DockControl/C1DockGroup uses their Items property for handling Docking/Undocking i.e Items get added and removed which won’t be possible if ItemsSource is used. Therefore, It can’t be implemented.

    Please refer here for more information:

    https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.itemscontrol.itemssource?view=netframework-4.8

    Regards,

    Kartik.

Need extra support?

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

Learn More

Forum Channels