fsprojects / Avalonia.FuncUI

Develop cross-plattform GUI Applications using F# and Avalonia!
https://funcui.avaloniaui.net/
MIT License
889 stars 72 forks source link

TreeDataGrid Support #386

Open GallaFrancesco opened 5 months ago

GallaFrancesco commented 5 months ago

Are there any plans to support TreeDataGrid in FuncUI?

It should be possible to use it in place of DataGrid with the additional benefits of having TreeView on top and other perks such as SelectableTextBlock by default on DataGridTextColumn.

Numpsy commented 5 months ago

I've been making some simple use of it in a FuncUI application and there could be some 'official' bindings for it, though I don't think the core library should depend on it.

GallaFrancesco commented 5 months ago

Why not? The DataGrid control is supported and it's managed by the Avalonia organization as well. I know TreeDataGrid is a separate package but technically DataGrid is as well, even though the sources are in the AvaloniaUI repo https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls.DataGrid/DataGrid.cs

JaggerJo commented 5 months ago

Would you contribute the bindings?

I'm not entirely happy with how we included the bindings for data grid in the main library. This creates a transitive dependency on Avalonia.Controls.DataGrid for all projects referencing FuncUI.

We should have small binding packages for control libraries.

Numpsy commented 5 months ago

TreeDataGrid also has a dependency on System.Reactive, which is quite large itself, so I don't think forcing a dependency is ideal (not my descision of course)

JaggerJo commented 5 months ago

TreeDataGrid also has a dependency on System.Reactive, which is quite large itself, so I don't think forcing a dependency is ideal (not my descision of course)

💯 agreed.

Numpsy commented 5 months ago

Hmm, had a look at my usage of TreeDataGrid and it's basically all code behind style and no real bindings - e.g. doing things like

let makeTreeDataSource initialItems =
    let gridSauce =
        new HierarchicalTreeDataGridSource<StructuredSectionContent>(items = initialItems)

    gridSauce.Columns.Add(
        HierarchicalExpanderColumn<StructuredSectionContent>(
            TextColumn<StructuredSectionContent, string>("Name", (fun section -> section.DisplayName)),
            (fun x -> x.SubSections),
            (fun x -> not (Seq.isEmpty x.SubSections))
        )
    )

    gridSauce.Columns.Add(
        TextColumn<StructuredSectionContent, string>("Value", (fun section -> section.DisplayValue))
    )

    gridSauce

and then just assigning that to the Source property of the grid in an init function.