can't create a Gtk.ListStore or Gtk.TreeStore
It's not possible to use the Gtk.TreeView class in Gir.Core GTK 4 in C#. The problem is that to use a TreeView you would need a Gtk.ListStore or a Gtk.TreeStore, and Gir.Core doesn't expose any ListStore or TreeStore constructor that would let you specify the number of columns or their types.
In C there is a function gtk_list_store_newv(int n_columns, GType* types):
https://docs.gtk.org/gtk4/ctor.ListStore.newv.html
But in Gir.Core, the only accessible constructors for Gtk.ListStore don't have n_columns or a GType array.
They are
public ListStore(params ConstructArgument[] constructArguments)
and
public ListStore(ListStoreHandle handle)
The situation with Gtk.TreeStore is similar.
https://docs.gtk.org/gtk4/ctor.TreeStore.newv.html
Would it be possible in an update to provider the constructors?
Thank you
The constructor can not be provided as they require “VarArgs” which are not supported by dotnet as far as I know.
But it should be checked why api like https://docs.gtk.org/gtk4/method.TreeStore.set_column_types.html is not available.
Both ListStore and TreeStore are deprecated for a few years now...
For what it's worth, I was able to get this working in an older version of gircore (maybe it still works with the current version - not sure):
https://github.com/hol430/NCBrowse/blob/master/src/NCBrowse/Frontend/Helpers/GenericListView.cs
As @UrtsiSantsi said though, this is an old part of the api and there are probably better ways to do what you want these days.