summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/Cells/SwitchCell.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/Cells/SwitchCell.cs')
-rw-r--r--Xamarin.Forms.Core/Cells/SwitchCell.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/Cells/SwitchCell.cs b/Xamarin.Forms.Core/Cells/SwitchCell.cs
new file mode 100644
index 00000000..adab7f45
--- /dev/null
+++ b/Xamarin.Forms.Core/Cells/SwitchCell.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace Xamarin.Forms
+{
+ public class SwitchCell : Cell
+ {
+ public static readonly BindableProperty OnProperty = BindableProperty.Create("On", typeof(bool), typeof(SwitchCell), false, propertyChanged: (obj, oldValue, newValue) =>
+ {
+ var switchCell = (SwitchCell)obj;
+ EventHandler<ToggledEventArgs> handler = switchCell.OnChanged;
+ if (handler != null)
+ handler(obj, new ToggledEventArgs((bool)newValue));
+ }, defaultBindingMode: BindingMode.TwoWay);
+
+ public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(SwitchCell), default(string));
+
+ public bool On
+ {
+ get { return (bool)GetValue(OnProperty); }
+ set { SetValue(OnProperty, value); }
+ }
+
+ public string Text
+ {
+ get { return (string)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+
+ public event EventHandler<ToggledEventArgs> OnChanged;
+ }
+} \ No newline at end of file