GtkSharp/Source/Samples/Sections/Widgets/SwitchSection.cs

27 lines
646 B
C#
Raw Normal View History

2018-01-27 19:12:24 +00:00
// This is free and unencumbered software released into the public domain.
// Happy coding!!! - GtkSharp Team
using Gtk;
namespace Samples
{
2018-01-27 20:47:02 +00:00
[Section(ContentType = typeof(Switch), Category = Category.Widgets)]
class SwitchSection : ListSection
2018-01-27 19:12:24 +00:00
{
2018-01-27 20:47:02 +00:00
public SwitchSection()
2018-01-27 19:12:24 +00:00
{
AddItem(CreateSwitchButton());
}
public (string, Widget) CreateSwitchButton()
{
var btn = new Switch();
btn.ButtonReleaseEvent += (o, args) =>
ApplicationOutput.WriteLine(o, $"Switch is now: {!btn.Active}");
return ("Switch:", btn);
}
}
}