using Gtk; VBox vbox = new VBox(false, 0); Label label1 = new Label("Hello"); Label label2 = new Label("World"); vbox.PackStart(label1, false, false, 0); vbox.PackStart(label2, false, false, 0);
using Gtk; public class MyWidget : VBox { public MyWidget() { Label label1 = new Label("Hello"); Label label2 = new Label("World"); PackStart(label1, false, false, 0); PackStart(label2, false, false, 0); } }In this example, we define a custom widget class called MyWidget that extends the VBox class. We override the default constructor of the VBox class to add two child Label widgets using the PackStart method. This custom widget can now be used in any Gtk# application just like any other widget. Package library: Gtk# (https://www.nuget.org/packages/GtkSharp/4.0.6-beta1)