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

33 lines
858 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(ToggleButton), Category = Category.Widgets)]
2018-01-27 19:12:24 +00:00
class ToggleButtonSection : ListSection
{
public ToggleButtonSection()
{
AddItem(CreateToggleButton());
}
public (string, Widget) CreateToggleButton()
{
var btn = new ToggleButton("Toggle Me");
btn.Toggled += (sender, e) =>
{
if (btn.Active)
btn.Label = "Untoggle Me";
else
btn.Label = "Toglle Me";
ApplicationOutput.WriteLine(sender, "Buton Toggled");
};
return ("Toggle button:", btn);
}
}
}