mono / gtk-sharp

Gtk# is a Mono/.NET binding to the cross platform Gtk+ GUI toolkit and the foundation of most GUI apps built with Mono
http://www.mono-project.com/GtkSharp
Other
428 stars 139 forks source link

NodeView does't show on win10 compile by vs2017 #256

Open sarimoly opened 5 years ago

sarimoly commented 5 years ago

Steps to Reproduce

  1. I follow this tutorial on windows use vs2017 https://www.mono-project.com/docs/gui/gtksharp/widgets/nodeview-tutorial-examples/
  2. download gtk-sharp-2.12.45.msi from https://www.mono-project.com/download/stable/
  3. create an empty project in vs2017, add 7 dll in my project, add following code, compile ok,
  4. the data in NodeView didn't show, just empty.
namespace Project1
{
    public class NodeViewExample : Gtk.Window
    {
        public NodeViewExample() : base("NodeView")
        {
            SetSizeRequest(200, 150);

            // Create our TreeView and add it as our child widget
            Gtk.NodeView view = new Gtk.NodeView(Store);
            Add(view);

            // Create a column with title Artist and bind its renderer to model column 0
            view.AppendColumn("Artist", new Gtk.CellRendererText(), "text", 0);

            // Create a column with title 'Song Title' and bind its renderer to model column 1
            view.AppendColumn("Song Title", new Gtk.CellRendererText(), "text", 1);
            view.ShowAll();
        }

        protected override bool OnDeleteEvent(Gdk.Event ev)
        {
            Gtk.Application.Quit();
            return true;
        }
        Gtk.NodeStore store;
        Gtk.NodeStore Store
        {
            get
            {
                if (store == null)
                {
                    store = new Gtk.NodeStore(typeof(MyTreeNode));
                    store.AddNode(new MyTreeNode("The Beatles", "Yesterday"));
                    store.AddNode(new MyTreeNode("Peter Gabriel", "In Your Eyes"));
                    store.AddNode(new MyTreeNode("Rush", "Fly By Night"));
                }
                return store;
            }
        }
        public static void Main()
        {
            Gtk.Application.Init();
            NodeViewExample win = new NodeViewExample();
            win.Show();
            Gtk.Application.Run();
        }
    }
}

Current Behavior

the NodeView is empty.

Expected Behavior

it should contain 3 row data and 1 line column header.

Artist Song Title
The Beatles Yesterday
Peter Gabriel In Your Eyes
Rush Fly By Night

On which platforms did you notice this

[ ] macOS [ ] Linux [*] Windows

win 10:

Stacktrace

Please paste the stack trace here if available.
sarimoly commented 5 years ago

no stack trace, the program didn't crash