summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs
new file mode 100644
index 00000000..c2502339
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs
@@ -0,0 +1,47 @@
+using System.Linq;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public class SwitchCellItem
+ {
+ public string Label { get; set; }
+ public bool SwitchOn { get; set; }
+ }
+
+ public class SwitchCellListPage : ContentPage
+ {
+ public SwitchCellListPage ()
+ {
+ Title = "SwitchCell List Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var dataTemplate = new DataTemplate (typeof (SwitchCell)) {
+ Bindings = {
+ {SwitchCell.TextProperty, new Binding ("Label")},
+ {SwitchCell.OnProperty, new Binding ("SwitchOn")},
+ }
+ };
+
+ var label = new Label { Text = "I have not been selected" };
+
+ var listView = new ListView {
+ ItemsSource = Enumerable.Range (0, 100).Select (i => new SwitchCellItem {
+ Label = "Label " + i,
+ SwitchOn = i % 2 == 0 ? false : true,
+ }),
+ ItemTemplate = dataTemplate
+ };
+
+ listView.ItemSelected += (sender, args) => label.Text = "I was selected.";
+
+ Content = new StackLayout { Children = { label, listView } };
+ }
+
+ }
+} \ No newline at end of file