--- /dev/null
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Switch;
+
+ public static class Switch
+ {
+ public static readonly BindableProperty SwitchStyleProperty = BindableProperty.Create("SwitchStyle", typeof(SwitchStyle), typeof(FormsElement), SwitchStyle.Default);
+
+ public static SwitchStyle GetSwitchStyle(BindableObject element)
+ {
+ return (SwitchStyle)element.GetValue(SwitchStyleProperty);
+ }
+
+ public static void SetSwitchStyle(BindableObject element, SwitchStyle value)
+ {
+ element.SetValue(SwitchStyleProperty, value);
+ }
+
+ public static SwitchStyle GetSwitchStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetSwitchStyle(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetSwitchStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config, SwitchStyle value)
+ {
+ SetSwitchStyle(config.Element, value);
+ return config;
+ }
+ }
+}
--- /dev/null
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ public enum SwitchStyle
+ {
+ Default,
+ CheckBox,
+ Favorite
+ }
+}
<Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\Button.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\ButtonStyle.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Switch.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\SwitchStyle.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
<Compile Include="Configuration.cs" />
using System;
+using System.ComponentModel;
using ElmSharp;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Switch;
namespace Xamarin.Forms.Platform.Tizen
{
if (e.NewElement != null)
{
- Control.Style = "toggle";
-
+ UpdateStyle();
Control.StateChanged += CheckChangedHandler;
}
base.OnElementChanged(e);
}
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == Specific.SwitchStyleProperty.PropertyName)
+ {
+ UpdateStyle();
+ }
+ base.OnElementPropertyChanged(sender, e);
+ }
+
void CheckChangedHandler(object sender, EventArgs e)
{
Element.SetValue(Switch.IsToggledProperty, Control.IsChecked);
Control.IsChecked = Element.IsToggled;
}
+ void UpdateStyle()
+ {
+ switch (Specific.GetSwitchStyle(Element))
+ {
+ case SwitchStyle.CheckBox:
+ Control.Style = "default";
+ break;
+ case SwitchStyle.Favorite:
+ Control.Style = "favorite";
+ break;
+ default:
+ Control.Style = "toggle";
+ break;
+ }
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
}
}