Populating the Tree structure with C1Treeview not working

Posted by: mayur.purandare on 22 June 2023, 4:24 pm EST

    • Post Options:
    • Link

    Posted 22 June 2023, 4:24 pm EST - Updated 22 June 2023, 4:29 pm EST

    Hello,

    We are working on a functionality wherein we need to populate a tree structure dynamically in a Treeview.

    We could do this with regular WPF Treeview and HierarchicalDataTemplate.

    However, when we tried to do the same with C1Treeview and C1HierarchicalDataTemplate, it is not working. (Ref File: Screenshot.jpg)

    The DataModel used is as shown in the attachment : DataModel.png

    Sharing also the sample application wherein WPF and C1 Treeview is used to populate the tree structure.

    Treeview-Query-App.zip

    Request your support for the same.

    Thank you.

  • Posted 25 June 2023, 9:43 pm EST

    Hi Mayur,

    Thanks for reaching out to us with your query.

    We are in discussions with the developers regarding this requirement. [Internal Tracking ID: C1XAML-34535]

    We will update you on this as soon as we hear back from them.

    Thanks & Regards

    Aastha

  • Posted 27 June 2023, 3:59 am EST

    Hello Aastha,

    Thank you for the reply.

    Is there any update on this?

    Regards,

    Mayur

  • Posted 27 June 2023, 2:36 pm EST

    Hi Mayur,

    You can use your custom ItemTemplateSelector for the C1TreeView control in order to handle this use-case scenario. We have attached the updated sample application for your reference. Please check TreeViewBindingHierarchy-fixed.zip

    Hope this helps!

    Thanks & Regards,

    Aastha

  • Posted 27 June 2023, 3:12 pm EST

    Hello Aastha,

    Thank you.

    It is working.

  • Posted 13 September 2023, 10:00 pm EST - Updated 13 September 2023, 10:05 pm EST

    Hello,

    Is there any way to disable the selection of group nodes?

    For example: in the attached screenshot, I want to disable the selection of nodes “Container Supported Units” and “Sub Units”

  • Posted 16 September 2023, 1:11 am EST

    Hi Mayur,

    You can handle C1TreeView’s SelectionChanged event to disable selection of C1TreeViewItems having ModuleCollectionsViewModel type object as its DataContext. Please refer to the following lines of code for the same:

    private void treeView_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var selectedNode = treeView.SelectedItem as C1TreeViewItem;
        if(selectedNode != null && selectedNode.DataContext != null &&
        selectedNode.DataContext.GetType() == typeof(ModuleCollectionsViewModel))
        {
            selectedNode.IsSelected = false;
        }            
    }

    Kindly to the attached sample for full implementation. (See TreeViewBindingHierarchy_Mod.zip)

    Thanks & Regards,

    Aastha

Need extra support?

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

Learn More

Forum Channels