GTK 中的 MessageBox 从未显示

MessageBox In GTK Never Shown

我在 OSX 上使用 VS Code 并尝试在我的按钮按下事件中向用户显示一个对话框。下面的代码是我的,但是当按下按钮时,对话框永远不会显示。

    public static void Main(string[] args)
    {
        Application.Init();

        MainWindow win = new MainWindow();

        Button btnClick = new Button("Button");
        win.Add(btnClick);

        btnClick.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressHandler);
        btnClick.Visible = true;
        win.Show();
        Application.Run();

    }

    private static void ButtonPressHandler(object obj, ButtonPressEventArgs args)
    {
        MessageDialog md = new MessageDialog(null, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, "You pressed the button!");
        md.Run();
        md.Destroy();
    }

我想你想要 btnClick.Clicked 而不是 btnClick.ButtonPressEvent。甚至似乎没有 ButtonPressEvent 成员。参见 http://docs.go-mono.com/?link=T%3aGtk.Button