Ooui-tws-port/Samples/ButtonSample.cs

41 lines
947 B
C#
Raw Normal View History

2017-06-15 06:38:58 +00:00
using System;
using Ooui;
namespace Samples
{
2017-11-10 06:35:47 +00:00
public class ButtonSample : ISample
2017-06-15 06:38:58 +00:00
{
2017-11-16 04:32:17 +00:00
public string Title => "Button Counter";
2018-09-02 04:56:35 +00:00
public string Path => "/shared-button";
2017-11-10 06:35:47 +00:00
2017-06-15 06:38:58 +00:00
Button MakeButton ()
{
2017-11-16 05:48:12 +00:00
var button = new Button ("Click me!") {
ClassName = "btn btn-primary", // Some bootstrap styling
};
button.Style.MarginTop = "2em";
2017-06-15 06:38:58 +00:00
var count = 0;
button.Click += (s, e) => {
2017-06-15 06:38:58 +00:00
count++;
button.Text = $"Clicked {count} times";
};
return button;
}
public void Publish ()
{
var b = MakeButton ();
2023-03-17 08:08:32 +00:00
Xamarin.Forms.PageExtensions.Ui.Publish (Path, b);
Xamarin.Forms.PageExtensions.Ui.Publish ("/button", MakeButton);
2017-06-15 06:38:58 +00:00
}
2017-11-10 06:35:47 +00:00
public Element CreateElement ()
{
return MakeButton ();
}
2017-06-15 06:38:58 +00:00
}
}