如何在c#GTK mono中将背景色设置为固定?

如何在c#GTK mono中将背景色设置为固定?,c#,gtk,monodevelop,C#,Gtk,Monodevelop,我对单声道C#Gtk还不熟悉。我用以下代码制作了一个带有两个按钮的窗口: using Gtk; using Gdk; class FirstScreen : Gtk.Window { public FirstScreen() : base("Buttons") { SetDefaultSize(250, 200); SetPosition(WindowPosition.Center); DeleteEvent += delegate { Application.Qu

我对单声道C#Gtk还不熟悉。我用以下代码制作了一个带有两个按钮的窗口:

using Gtk;
using Gdk;

class FirstScreen : Gtk.Window
{

public FirstScreen() : base("Buttons")
{
    SetDefaultSize(250, 200);
    SetPosition(WindowPosition.Center);

    DeleteEvent += delegate { Application.Quit(); };

    Fixed fix = new Fixed();

    Button btn1 = new Button("Take Photo");

    Button btn2 = new Button("Take Video");

    Gdk.Color col = new Gdk.Color();
    Gdk.Color.Parse("red", ref col);
    fix.(StateType.Normal, col);

    fix.Put(btn1,30, 80);
    fix.Put(btn2, 130, 80);


    Add(fix);
    ShowAll();
}


public static void Main() 
{
    Application.Init();
    new FirstScreen();
    Application.Run();
}
}


我想更改窗口或固定窗口的背景色。我们如何更改,请帮助?

默认情况下
Gtk。固定窗口没有自己的
Gdk。窗口
但在其父窗口上绘制,并且不绘制任何背景。要让它绘制背景,只需告诉它创建自己的
Gdk.Window

fix.HasWindow = true;

仅此而已。

您可以尝试使用eventbox。并在框中建立您的对象。例如:

eventbox.ModifyBg (StateType.Normal, new Gdk.Color (0, 0, 0));  //Zeros represent of (r,g,b) 

嗨,福格,我有个大问题。你有GTK mono的经验吗?你能帮我聊天吗?@NavdeepSinghBedi当然。我有一个c#GTK#的项目,使用网络摄像头,你能帮我吗?@NavdeepSinghBedi是的,但是你为什么不在stackoverlow上问一下呢?我在google上花了大约一周的时间搜索,在stackoverlow上也问了一个问题,没有人回答,只有-ve分……我已经为运行在windows上的visual C开发了代码,但我需要它在Ubuntu Linux上运行。