Ooui-tws-port/Samples/SliderSample.cs

61 lines
1.4 KiB
C#
Raw Normal View History

2017-12-29 11:55:47 +00:00
using Ooui;
using System;
using Xamarin.Forms;
namespace Samples
{
public class SliderSample : ISample
{
private Xamarin.Forms.Label _label;
public string Title => "Xamarin.Forms Slider Sample";
2018-09-02 04:56:35 +00:00
public string Path => "/slider";
2017-12-29 11:55:47 +00:00
public Ooui.Element CreateElement()
{
var panel = new StackLayout();
var titleLabel = new Xamarin.Forms.Label
{
Text = "Slider",
FontSize = 24,
FontAttributes = FontAttributes.Bold
};
panel.Children.Add(titleLabel);
Slider slider = new Slider
{
Minimum = 0,
Maximum = 100
};
panel.Children.Add(slider);
slider.ValueChanged += OnSliderValueChanged;
_label = new Xamarin.Forms.Label
{
Text = "Slider value is 0",
HorizontalOptions = LayoutOptions.Center
};
panel.Children.Add(_label);
var page = new ContentPage
{
Content = panel
};
return page.GetOouiElement();
}
void OnSliderValueChanged(object sender, ValueChangedEventArgs e)
{
_label.Text = String.Format("Slider value is {0:F1}", e.NewValue);
}
public void Publish()
{
2018-09-02 04:56:35 +00:00
UI.Publish(Path, CreateElement);
2017-12-29 11:55:47 +00:00
}
}
}