Ooui-tws-port/Samples/XamarinFormsSample.cs

58 lines
1.4 KiB
C#
Raw Normal View History

2017-11-09 07:12:59 +00:00
using System;
using Xamarin.Forms;
using Ooui.Forms;
namespace Samples
{
2017-11-10 06:35:47 +00:00
public class XamarinFormsSample : ISample
2017-11-09 07:12:59 +00:00
{
2017-11-10 06:35:47 +00:00
public string Title => "Xamarin.Forms Button Counter";
2017-11-10 01:23:41 +00:00
Page MakePage ()
2017-11-09 07:12:59 +00:00
{
Forms.Init ();
var countLabel = new Label {
Text = "0",
2017-11-09 22:17:36 +00:00
BackgroundColor = Color.Gold,
2017-11-10 01:23:41 +00:00
HorizontalOptions = LayoutOptions.Center,
2017-11-09 07:12:59 +00:00
};
var countButton = new Button {
2017-11-10 00:09:48 +00:00
Text = "Increase",
2017-11-10 01:23:41 +00:00
HorizontalOptions = LayoutOptions.FillAndExpand,
2017-11-09 07:12:59 +00:00
};
countButton.Clicked += (sender, e) => {
var v = int.Parse (countLabel.Text);
countLabel.Text = (v + 1).ToString ();
};
2017-11-10 01:23:41 +00:00
return new ContentPage {
Content = new StackLayout {
2017-11-09 22:17:36 +00:00
BackgroundColor = Color.Khaki,
2017-11-10 01:23:41 +00:00
Children = {
new Label {
Text = "Hello World!",
FontSize = 32,
HorizontalOptions = LayoutOptions.Center,
},
2017-11-09 07:12:59 +00:00
countLabel,
countButton,
},
},
};
2017-11-10 01:23:41 +00:00
}
2017-11-09 07:12:59 +00:00
2017-11-10 01:23:41 +00:00
public void Publish ()
{
var page = MakePage ();
page.Publish ("/xamarin-forms-shared");
Ooui.UI.Publish ("/xamarin-forms", () => MakePage ().CreateElement ());
}
2017-11-10 06:35:47 +00:00
public Ooui.Element CreateElement ()
{
return MakePage ().CreateElement ();
}
}
2017-11-09 07:12:59 +00:00
}