summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 13:02:25 -0700
committerJason Smith <jason.smith@xamarin.com>2016-03-22 16:13:41 -0700
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Controls/GalleryPages
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
Initial import
Diffstat (limited to 'Xamarin.Forms.Controls/GalleryPages')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs151
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ActionSheetGallery.cs64
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/AlertGallery.cs28
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/BackgroundImageGallery.cs109
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/BoundContentPage.cs79
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs115
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CarouselPageGallery.cs76
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs292
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellTypeList.cs63
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs54
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs85
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs121
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs68
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs33
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs47
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs65
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs48
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs58
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/UnEvenViewCellGallery.cs34
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs115
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ClipToBoundsGallery.cs31
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs48
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml24
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml.cs31
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs58
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/EditableList.cs116
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/EditorGallery.cs132
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/EntryGallery.cs104
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs32
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/GridGallery.cs174
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/GroupedListActionsGallery.cs282
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/GroupedListContactsGallery.cs244
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ImageGallery.cs71
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ImageLoadingGallery.cs43
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/InputIntentGallery.cs101
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs116
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/LayoutOptionsGallery.cs108
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/LayoutPerformanceGallery.cs116
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/LineBreakModeGallery.cs41
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ListPage.cs117
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs231
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/MapGallery.cs153
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs40
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/MinimumSizeGallery.cs50
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/MultiGallery.cs58
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/NavigationBarGallery.cs62
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/NavigationMenuGallery.cs38
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/NavigationPropertiesGallery.cs64
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/OpenGLGallery.cs70
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/PickerGallery.cs45
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ProgressBarGallery.cs26
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs47
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ScaleRotate.cs157
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ScrollGallery.cs158
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/SearchBarGallery.cs128
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/SettingsPage.cs57
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/SliderGallery.cs33
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs47
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/StepperGallery.cs49
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/StyleGallery.cs41
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml17
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml.cs15
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/SwitchGallery.cs53
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/TableViewGallery.cs24
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/TemplatedCarouselGallery.cs114
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/TemplatedTabbedGallery.cs169
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ToolbarGallery.cs40
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/UnevenListGallery.cs112
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/WebViewGallery.cs50
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml4
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml.cs13
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/crimson.jpgbin0 -> 79109 bytes
72 files changed, 5859 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs
new file mode 100644
index 00000000..b38798f1
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ internal class AbsolutePositioningExplorationViewModel : INotifyPropertyChanged
+ {
+ double _rectangleX = 0.5;
+ double _rectangleY = 0.5;
+ double _rectangleWidth = 0.5;
+ double _rectangleHeight = 0.5;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged ([CallerMemberName] string propertyName = null)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ handler (this, new PropertyChangedEventArgs (propertyName));
+ }
+
+ public double RectangleX
+ {
+ get { return _rectangleX; }
+ set
+ {
+ if (_rectangleX == value)
+ return;
+ _rectangleX = value;
+ OnPropertyChanged ();
+ OnPropertyChanged ("Rectangle");
+ }
+ }
+
+ public double RectangleY
+ {
+ get { return _rectangleY; }
+ set
+ {
+ if (_rectangleY == value)
+ return;
+ _rectangleY = value;
+ OnPropertyChanged ();
+ OnPropertyChanged ("Rectangle");
+ }
+ }
+
+ public double RectangleWidth
+ {
+ get { return _rectangleWidth; }
+ set
+ {
+ if (_rectangleWidth == value)
+ return;
+ _rectangleWidth = value;
+ OnPropertyChanged ();
+ OnPropertyChanged ("Rectangle");
+ }
+ }
+
+ public double RectangleHeight
+ {
+ get { return _rectangleHeight; }
+ set
+ {
+ if (_rectangleHeight == value)
+ return;
+ _rectangleHeight = value;
+ OnPropertyChanged ();
+ OnPropertyChanged ("Rectangle");
+ }
+ }
+
+ public Rectangle Rectangle
+ {
+ get { return new Rectangle(RectangleX, RectangleY, RectangleWidth, RectangleHeight); }
+ }
+ }
+ public class AbsoluteLayoutGallery : ContentPage
+ {
+ public AbsoluteLayoutGallery ()
+ {
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ BindingContext = new AbsolutePositioningExplorationViewModel ();
+ var absLayout = new AbsoluteLayout {
+ BackgroundColor = Color.Gray,
+ VerticalOptions = LayoutOptions.FillAndExpand
+ };
+
+ var rect = new BoxView {Color = Color.Lime};
+
+ var xSlider = new Slider ();
+ var ySlider = new Slider ();
+ var widthSlider = new Slider ();
+ var heightSlider = new Slider ();
+
+ var grid = new Grid {
+ Padding = 10,
+ RowSpacing = 0,
+ ColumnDefinitions = {
+ new ColumnDefinition {Width = GridLength.Auto},
+ new ColumnDefinition {Width = new GridLength (1, GridUnitType.Star)}
+ }
+ };
+
+ grid.Children.Add (new Label {Text = "X:", VerticalTextAlignment = TextAlignment.Center}, 0, 0);
+ grid.Children.Add (xSlider, 1, 0);
+
+ grid.Children.Add (new Label {Text = "Y:", VerticalTextAlignment = TextAlignment.Center}, 0, 1);
+ grid.Children.Add (ySlider, 1, 1);
+
+ grid.Children.Add (new Label {Text = "Width:", VerticalTextAlignment = TextAlignment.Center}, 0, 2);
+ grid.Children.Add (widthSlider, 1, 2);
+
+ grid.Children.Add (new Label {Text = "Height:", VerticalTextAlignment = TextAlignment.Center}, 0, 3);
+ grid.Children.Add (heightSlider, 1, 3);
+
+ absLayout.Children.Add (rect);
+
+ var mainLayout = new StackLayout {
+ Spacing = 0,
+ Children = {
+ absLayout,
+ grid
+ }
+ };
+
+ rect.SetBinding (AbsoluteLayout.LayoutBoundsProperty, "Rectangle");
+ AbsoluteLayout.SetLayoutFlags (rect, AbsoluteLayoutFlags.All);
+
+ xSlider.SetBinding (Slider.ValueProperty, new Binding ("RectangleX", BindingMode.TwoWay));
+ ySlider.SetBinding (Slider.ValueProperty, new Binding ("RectangleY", BindingMode.TwoWay));
+ widthSlider.SetBinding (Slider.ValueProperty, new Binding ("RectangleWidth", BindingMode.TwoWay));
+ heightSlider.SetBinding (Slider.ValueProperty, new Binding ("RectangleHeight", BindingMode.TwoWay));
+
+ //Content = new ScrollView {Content = mainLayout};
+ Content = mainLayout;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ActionSheetGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ActionSheetGallery.cs
new file mode 100644
index 00000000..4f60c1e1
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ActionSheetGallery.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ActionSheetGallery : ContentPage
+ {
+ public ActionSheetGallery ()
+ {
+ AutomationId = "ActionSheetPage";
+
+ var extras = new string[] {
+ "Extra One",
+ "Extra Two",
+ "Extra Three",
+ "Extra Four",
+ "Extra Five",
+ "Extra Six",
+ "Extra Seven",
+ "Extra Eight",
+ "Extra Nine",
+ "Extra Ten",
+ "Extra Eleven",
+ };
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Spacing = 0,
+ Children = {
+ MakeActionSheetButton (this, "ActionSheet Cancel", null, "Cancel", null),
+ MakeActionSheetButton (this, "ActionSheet Cancel Extras", null, "Cancel", null, extras),
+ MakeActionSheetButton (this, "ActionSheet Cancel Destruction", null, "Cancel", "Destruction"),
+ MakeActionSheetButton (this, "ActionSheet Cancel Destruction Extras", null, "Cancel", "Destruction", extras),
+ MakeActionSheetButton (this, "ActionSheet Destruction", null, null, "Destruction"),
+ MakeActionSheetButton (this, "ActionSheet Destruction Extras", null, null, "Destruction", extras),
+ MakeActionSheetButton (this, "ActionSheet Extras", null, null, null, extras),
+ MakeActionSheetButton (this, "ActionSheet Title", "Title", null, null),
+ MakeActionSheetButton (this, "ActionSheet Title Cancel", "Title", "Cancel", null),
+ MakeActionSheetButton (this, "ActionSheet Title Cancel Extras", "Title", "Cancel", null, extras),
+ MakeActionSheetButton (this, "ActionSheet Title Cancel Destruction", "Title", "Cancel", "Destruction"),
+ MakeActionSheetButton (this, "ActionSheet Title Cancel Destruction Extras", "Title", "Cancel", "Destruction", extras),
+ MakeActionSheetButton (this, "ActionSheet Title Destruction", "Title", null, "Destruction"),
+ MakeActionSheetButton (this, "ActionSheet Title Destruction Extras", "Title", null, "Destruction", extras),
+ MakeActionSheetButton (this, "ActionSheet Title Extras", "Title", null, null, extras),
+ }
+ }
+ };
+ }
+
+ static Button MakeActionSheetButton (Page page, string buttonText, string title, string cancel, string destruction, params string[] extras)
+ {
+ var actionSheetButton = new Button {
+ Text = buttonText
+ };
+
+ actionSheetButton.Clicked += async (sender, e) => await page.DisplayActionSheet (title, cancel, destruction, extras);
+
+ return actionSheetButton;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/AlertGallery.cs b/Xamarin.Forms.Controls/GalleryPages/AlertGallery.cs
new file mode 100644
index 00000000..8a666a10
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/AlertGallery.cs
@@ -0,0 +1,28 @@
+using System;
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Controls
+{
+ public class AlertGallery : ContentPage
+ {
+ public AlertGallery ()
+ {
+ var lblResult = new Label { Text = "Result: ", AutomationId = "testResult" };
+
+ var btn1 = new Button { Text = "Alert Override1", AutomationId = "test1" };
+ btn1.Clicked += async (sender, e) => {
+ await DisplayAlert ("TheAlertTitle", "TheAlertMessage", "TheCancelButton");;
+ };
+
+ var btn2 = new Button { Text = "Alert Override2", AutomationId = "test2" };
+ btn2.Clicked += async (sender, e) => {
+ var result = await DisplayAlert ("TheAlertTitle", "TheAlertMessage", "TheAcceptButton", "TheCancelButton");
+ lblResult.Text = string.Format("Result: {0}", result);
+ };
+
+ Content = new StackLayout { Children = { lblResult, btn1, btn2 }};
+ }
+ }
+}
+
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/BackgroundImageGallery.cs b/Xamarin.Forms.Controls/GalleryPages/BackgroundImageGallery.cs
new file mode 100644
index 00000000..7282a0ed
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/BackgroundImageGallery.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class BackgroundImageGallery
+ : ContentPage
+ {
+ public BackgroundImageGallery ()
+ {
+ var contentIntabs = new Button { Text = "Tabbed children" };
+ contentIntabs.Clicked += async (sender, args) => {
+ await Navigation.PushModalAsync (new TabbedPage {
+ ItemTemplate = new DataTemplate (() => {
+ var page = new ContentPage();
+ page.SetBinding (BackgroundImageProperty, ".");
+ return page;
+ }),
+
+ ItemsSource = new[] {
+ "oasis.jpg",
+ "crimson.jpg"
+ }
+ /*ItemsSource = new[] {
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-21.jpg",
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-31.jpg",
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-61.jpg",
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-71.jpg"
+ };*/
+ });
+ };
+
+ var contentInCarosel = new Button { Text = "Carousel children" };
+ contentInCarosel.Clicked += async (sender, args) => {
+ await Navigation.PushModalAsync (new CarouselPage {
+ ItemTemplate = new DataTemplate (() => {
+ var page = new ContentPage();
+ page.SetBinding (BackgroundImageProperty, ".");
+ return page;
+ }),
+
+ ItemsSource = new[] {
+ "oasis.jpg",
+ "crimson.jpg"
+ }
+ /*ItemsSource = new[] {
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-21.jpg",
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-31.jpg",
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-61.jpg",
+ "http://www.zemwallpaper.com/wp-content/uploads/2014/05/Desktop-background-download-71.jpg"
+ };*/
+ });
+ };
+
+ var navigation = new Button { Text = "NavigationPage"};
+ navigation.Clicked += async (sender, args) => {
+ await Navigation.PushModalAsync (new NavigationPage (new ContentPage {
+ Content = new Label {
+ Text = "Text",
+ FontSize = 42
+ }})
+ {
+ BackgroundImage = "oasis.jpg"
+ }
+ );
+ };
+
+ var carousel = new Button { Text = "CarouselPage" };
+ carousel.Clicked += async (sender, args) => {
+ await Navigation.PushAsync (new CarouselPage {
+ BackgroundImage = "crimson.jpg",
+ ItemsSource = new[] { "test1", "test2" }
+ });
+ };
+
+ var tabbed = new Button { Text = "TabbedPage" };
+ tabbed.Clicked += async (sender, args) => {
+ await Navigation.PushAsync (new TabbedPage {
+ BackgroundImage = "crimson.jpg",
+ ItemsSource = new[] { "test1", "test2" }
+ });
+ };
+
+ var master = new Button { Text = "MasterDetail" };
+ master.Clicked += async (sender, args) => {
+ await Navigation.PushModalAsync (new MasterDetailPage {
+ Master = new ContentPage { Title = "Master" },
+ Detail = new ContentPage(),
+ BackgroundImage = "crimson.jpg",
+ });
+ };
+
+ Content = new StackLayout {
+ Children = {
+ navigation,
+ carousel,
+ tabbed,
+ master,
+ contentIntabs,
+ contentInCarosel
+ }
+
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/BoundContentPage.cs b/Xamarin.Forms.Controls/GalleryPages/BoundContentPage.cs
new file mode 100644
index 00000000..e3051fde
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/BoundContentPage.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Globalization;
+using System.Windows.Input;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public class BoundContentPage : ContentPage
+ {
+ internal class NavWrapperConverter : IValueConverter
+ {
+ public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException ();
+ }
+
+ public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return new NavigationWrapper ((INavigation) value);
+ }
+ }
+
+ internal class NavigationWrapper
+ {
+ // This class is dumb but proves you can wrap the INavigation with a converter to do some MVVM goodness
+ // Normally this class would implement pushes with ViewModel then do the conversion
+ readonly INavigation _inner;
+
+ public NavigationWrapper (INavigation inner )
+ {
+ _inner = inner;
+ }
+
+ public void WrappedPush ()
+ {
+ _inner.PushAsync (new ContentPage {
+ Content = new StackLayout {
+ BackgroundColor = Color.Red,
+ Children = {
+ new Label {
+ Text = "Second Page"
+ }
+ }
+ }
+ });
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class BoundContentPageViewModel
+ {
+ public string ButtonText { get { return "Click Me!"; } }
+
+ public ICommand ButtonCommand { get; set; }
+
+ public NavigationWrapper Navigation { get; set; }
+
+ public BoundContentPageViewModel ()
+ {
+ ButtonCommand = new Command (() => Navigation.WrappedPush ());
+ }
+ }
+
+ public BoundContentPage ()
+ {
+ Title ="Bound Gallery";
+
+ BindingContext = new BoundContentPageViewModel ();
+
+ var button = new Button ();
+ button.SetBinding (Button.TextProperty, "ButtonText");
+ button.SetBinding (Button.CommandProperty, "ButtonCommand");
+
+ SetBinding (NavigationProperty, new Binding ("Navigation", converter: new NavWrapperConverter ()));
+
+ Content = button;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs
new file mode 100644
index 00000000..bb276014
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ButtonGallery : ContentPage
+ {
+ public ButtonGallery ()
+ {
+ BackgroundColor = new Color (0.9);
+
+ var normal = new Button { Text = "Normal Button" };
+ normal.Effects.Add (Effect.Resolve ("XamControl.BorderEffect"));
+
+ var disabled = new Button { Text = "Disabled Button"};
+ var disabledswitch = new Switch ();
+ disabledswitch.SetBinding (Switch.IsToggledProperty, "IsEnabled");
+ disabledswitch.BindingContext = disabled;
+
+ var canTapLabel = new Label {
+ Text = "Cannot Tap"
+ };
+
+ disabled.Clicked += (sender, e) => {
+ canTapLabel.Text = "TAPPED!";
+ };
+
+ var click = new Button { Text = "Click Button" };
+ var rotate = new Button { Text = "Rotate Button" };
+ var transparent = new Button { Text = "Transparent Button" };
+
+ var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS");
+ var font = Font.OfSize (fontName, NamedSize.Medium);
+
+ var themedButton = new Button {
+ Text = "Accent Button",
+ BackgroundColor = Color.Accent,
+ TextColor = Color.White,
+ ClassId = "AccentButton",
+ Font = font
+ };
+ var borderButton = new Button {
+ Text = "Border Button",
+ BorderColor = Color.Black,
+ BackgroundColor = Color.Purple,
+ BorderWidth = 5,
+ BorderRadius = 5
+ };
+ var timer = new Button { Text = "Timer" };
+ var busy = new Button { Text = "Toggle Busy" };
+ var alert = new Button { Text = "Alert" };
+ var alertSingle = new Button {Text = "Alert Single"};
+ var image = new Button { Text = "Image Button", Image = new FileImageSource {File = "bank.png"}, BackgroundColor = Color.Blue.WithLuminosity (.8) };
+
+ themedButton.Clicked += (sender, args) => themedButton.Font = Font.Default;
+
+ alertSingle.Clicked += (sender, args) => DisplayAlert ("Foo", "Bar", "Cancel");
+
+ disabled.IsEnabled = false;
+ int i = 1;
+ click.Clicked += (sender, e) => { click.Text = "Clicked " + i++; };
+ rotate.Clicked += (sender, e) => rotate.RelRotateTo (180);
+ transparent.Opacity = .5;
+
+ int j = 1;
+ timer.Clicked += (sender, args) => Device.StartTimer (TimeSpan.FromSeconds (1), () => {
+ timer.Text = "Timer Elapsed " + j++;
+ return j < 4;
+ });
+
+ bool isBusy = false;
+ busy.Clicked += (sender, args) => IsBusy = isBusy = !isBusy;
+
+ alert.Clicked += async (sender, args) => {
+ var result = await DisplayAlert ("User Alert", "This is a user alert. This is only a user alert.", "Accept", "Cancel");
+ alert.Text = result ? "Accepted" : "Cancelled";
+ };
+
+ borderButton.Clicked += (sender, args) => borderButton.BackgroundColor = Color.Default;
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Padding = new Size (20, 20),
+ Children = {
+ normal,
+ new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children={
+ disabled,
+ disabledswitch,
+ },
+ },
+ canTapLabel,
+ click,
+ rotate,
+ transparent,
+ themedButton,
+ borderButton,
+ new Button {Text = "Thin Border", BorderWidth = 1, BackgroundColor=Color.White, BorderColor = Color.Black, TextColor = Color.Black},
+ new Button {Text = "Thinner Border", BorderWidth = .5, BackgroundColor=Color.White, BorderColor = Color.Black, TextColor = Color.Black},
+ timer,
+ busy,
+ alert,
+ alertSingle,
+ image,
+ }
+ }
+ };
+
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/CarouselPageGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CarouselPageGallery.cs
new file mode 100644
index 00000000..478b3018
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CarouselPageGallery.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+
+ public class CarouselPageGallery : CarouselPage
+ {
+ public CarouselPageGallery ()
+ {
+ var pageOneLabel = new Label {
+ Text = "No click one"
+ };
+
+ var pageTwoLabel = new Label {
+ Text = "No click two"
+ };
+
+ var pageThreeLabel = new Label {
+ Text = "No click three"
+ };
+
+ var pageOneButton = new Button {
+ Text = "Click me one",
+ Command = new Command (() => pageOneLabel.Text = "Clicked one")
+ };
+
+ var pageTwoButton = new Button {
+ Text = "Click me two",
+ Command = new Command (() => pageTwoLabel.Text = "Clicked two")
+ };
+
+ var pageThreeButton = new Button {
+ Text = "Click me three",
+ Command = new Command (() => pageThreeLabel.Text = "Clicked three")
+ };
+
+ Children.Add (new ContentPage {
+ Title = "Page One",
+ BackgroundColor = new Color (1, 0, 0),
+ Content = new StackLayout {
+ Children = {
+ pageOneLabel,
+ pageOneButton
+ }
+ }
+ });
+
+ Children.Add (new ContentPage {
+ Title = "Page Two",
+ BackgroundColor = new Color (0, 1, 0),
+ Content = new StackLayout {
+ Children = {
+ pageTwoLabel,
+ pageTwoButton
+ }
+ }
+ });
+
+ Children.Add (new ContentPage {
+ Title = "Page Three",
+ BackgroundColor = new Color (0, 0, 1),
+ Content = new StackLayout {
+ Children = {
+ pageThreeLabel,
+ pageThreeButton
+ }
+ }
+ });
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs
new file mode 100644
index 00000000..87f741cc
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs
@@ -0,0 +1,292 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Collections.ObjectModel;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public sealed class CarouselViewGallaryPage : ContentPage // or TestMasterDetailPage, etc ...
+ {
+ public abstract class Item
+ {
+ static int s_id = 0;
+
+ int id;
+
+ internal Item()
+ {
+ id = s_id++;
+ }
+
+ public int Id => id;
+ public string TypeName => GetType ().Name;
+ }
+ public sealed class Foo : Item { }
+ public sealed class Bar : Item { }
+ public sealed class Baz : Item { }
+ public sealed class Poo : Item { }
+ public sealed class Moo : Item { }
+
+ [Preserve (AllMembers = true)]
+ public sealed class ItemView : ContentView
+ {
+ public static readonly BindableProperty TextColorProperty = BindableProperty.Create (
+ propertyName: nameof(TextColor),
+ returnType: typeof (Color),
+ declaringType: typeof (ItemView),
+ defaultValue: Color.White,
+ defaultBindingMode: BindingMode.TwoWay
+ );
+ public static readonly BindableProperty ContextProperty = BindableProperty.Create (
+ propertyName: nameof(Context),
+ returnType: typeof (CarouselView),
+ declaringType: typeof (ItemView),
+ defaultBindingMode: BindingMode.TwoWay
+ );
+
+ public ItemView ()
+ {
+
+ var change = CreateButton("Change", (items, index) => items[index] = new Moo ());
+
+ var removeBar = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ Children = {
+ CreateButton ("- Left", (items, index) => items.RemoveAt (index - 1)),
+ CreateButton ("Remove", (items, index) => items.RemoveAt (index)),
+ CreateButton ("- Right", (items, index) => items.RemoveAt (index + 1)),
+ }
+ };
+
+ var addBar = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ Children = {
+ CreateButton ("+ Left", (items, index) => items.Insert (index, new Moo ())),
+ CreateButton ("+ Right", (items, index) => {
+ if (index == items.Count - 1)
+ items.Add (new Moo ());
+ else
+ items.Insert (index + 1, new Moo ());
+ }),
+ }
+ };
+
+ var typeNameLabel = new Label () { StyleId = "typename" };
+ typeNameLabel.SetBinding (Label.TextProperty, nameof(Item.TypeName));
+
+ var idLabel = new Label () { StyleId = "id", TextColor = Color.White };
+ idLabel.SetBinding (Label.TextProperty, nameof(Item.Id));
+
+ Content = new StackLayout {
+ Children = {
+ typeNameLabel,
+ idLabel,
+ change,
+ removeBar,
+ addBar,
+ }
+ };
+
+ PropertyChanged += (s, e) => {
+ if (e.PropertyName == "TextColor")
+ typeNameLabel.TextColor = TextColor;
+ };
+ }
+
+ Button CreateButton(string text, Action<IList<Item>, int> clicked)
+ {
+ var button = new Button ();
+ button.Text = text;
+ button.Clicked += (s, e) => {
+ var items = (IList<Item>)Context.ItemsSource;
+ var index = items.IndexOf (BindingContext);
+ clicked (items, index);
+ };
+ return button;
+ }
+
+ public CarouselView Context
+ {
+ get { return (CarouselView)GetValue (ContextProperty); }
+ set { SetValue (ContextProperty, value); }
+ }
+ public Color TextColor
+ {
+ get { return (Color)GetValue(TextColorProperty); }
+ set { SetValue(TextColorProperty, value); }
+ }
+ }
+ public sealed class MyDataTemplateSelector : DataTemplateSelector
+ {
+ Dictionary<Type, Color> m_colorByType = new Dictionary<Type, Color> ();
+ Dictionary<Type, DataTemplate> m_dataTemplateByType = new Dictionary<Type, DataTemplate> ();
+
+ public MyDataTemplateSelector()
+ {
+ m_colorByType[typeof (Foo)] = Color.Green;
+ m_colorByType[typeof (Bar)] = Color.Red;
+ }
+
+ protected override DataTemplate OnSelectTemplate (object item, BindableObject container)
+ {
+ return OnSelectTemplate (item.GetType (), container);
+ }
+
+ DataTemplate OnSelectTemplate (Type itemType, BindableObject container)
+ {
+ DataTemplate dataTemplate;
+ if (!m_dataTemplateByType.TryGetValue(itemType, out dataTemplate))
+ m_dataTemplateByType[itemType] = dataTemplate = CreateTemplate(itemType, container);
+ return dataTemplate;
+ }
+
+ DataTemplate CreateTemplate(Type itemType, BindableObject container)
+ {
+ var dataTemplate = new DataTemplate (typeof (ItemView));
+
+ Color color;
+ if (!m_colorByType.TryGetValue (itemType, out color)) {
+ color = Color.Pink;
+ dataTemplate.SetValue (BackgroundColorProperty, Color.Black);
+ } else {
+ dataTemplate.SetValue (BackgroundColorProperty, Color.Blue);
+ }
+
+ dataTemplate.SetValue (ItemView.TextColorProperty, color);
+ dataTemplate.SetValue (ItemView.ContextProperty, container);
+ return dataTemplate;
+ }
+ }
+
+ static readonly MyDataTemplateSelector Selector = new MyDataTemplateSelector ();
+
+ static readonly IList<Item> Items = new ObservableCollection<Item> () {
+ new Baz(),
+ new Poo(),
+ new Foo(),
+ new Bar(),
+ };
+
+ Button CreateButton(string text, Action onClicked = null)
+ {
+ var button = new Button {
+ Text = text
+ };
+
+ if (onClicked != null)
+ button.Clicked += (s, e) => onClicked();
+
+ return button;
+ }
+
+ public CarouselViewGallaryPage ()
+ {
+ BackgroundColor = Color.Blue;
+
+ var logLabel = new Label () { TextColor = Color.White };
+ var selectedItemLabel = new Label () { TextColor = Color.White, Text = "0" };
+ var selectedPositionLabel = new Label () { TextColor = Color.White, Text = "@0" };
+ //var appearingLabel = new Label () { TextColor = Color.White };
+ //var disappearingLabel = new Label () { TextColor = Color.White };
+
+ var carouselView = new CarouselView {
+ BackgroundColor = Color.Purple,
+ ItemsSource = Items,
+ ItemTemplate = Selector,
+ Position = 1
+ };
+
+ bool capture = false;
+ carouselView.ItemSelected += (s, o) => {
+ var item = (Item)o.SelectedItem;
+ selectedItemLabel.Text = $"{item.Id}";
+ if (capture)
+ logLabel.Text += $"({item.Id}) ";
+ };
+ carouselView.PositionSelected += (s, o) => {
+ var position = (int)o.SelectedPosition;
+ selectedPositionLabel.Text = $"@{position}=={carouselView.Position}";
+ if (capture)
+ logLabel.Text += $"(@{position}) ";
+ };
+ //carouselView.ItemDisappearing += (s, o) => {
+ // var item = (Item)o.Item;
+ // var id = item.Id;
+ // disappearingLabel.Text = $"-{id}";
+ // if (capture)
+ // logLabel.Text += $"(-{id}) ";
+ //};
+ //carouselView.ItemAppearing += (s, o) => {
+ // var item = (Item)o.Item;
+ // var id = item.Id;
+ // appearingLabel.Text = $"+{id}";
+ // if (capture)
+ // logLabel.Text += $"(+{id}) ";
+ //};
+
+ var moveBar = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ Children = {
+ CreateButton ("<<", () => carouselView.Position = 0),
+ CreateButton ("<", () => { try { carouselView.Position--; } catch { } }),
+ CreateButton (">", () => { try { carouselView.Position++; } catch { } }),
+ CreateButton (">>", () => carouselView.Position = Items.Count - 1)
+ }
+ };
+
+ var statusBar = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ selectedItemLabel,
+ selectedPositionLabel,
+ //disappearingLabel,
+ //appearingLabel,
+ }
+ };
+
+ var logBar = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ CreateButton ("Clear", () => logLabel.Text = ""),
+ CreateButton ("On/Off", () => capture = !capture ),
+ logLabel,
+ }
+ };
+
+ Content = new StackLayout {
+ Children = {
+ carouselView,
+ moveBar,
+ statusBar,
+ logBar
+ }
+ };
+ }
+
+#if UITEST
+ //[Test]
+ //public void CarouselViewTest ()
+ //{
+ // var app = RunningApp;
+ // app.Screenshot ("I am at Issue 1");
+ // app.WaitForElement (q => q.Marked ("Remove"));
+
+ // app.Screenshot ("I see the Label");
+ // app.SwipeRight ();
+ // app.SwipeLeft ();
+ //}
+#endif
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellTypeList.cs b/Xamarin.Forms.Controls/GalleryPages/CellTypeList.cs
new file mode 100644
index 00000000..4298bc81
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellTypeList.cs
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class CellTypesListPage : ContentPage
+ {
+ public CellTypesListPage ()
+ {
+ Content = new CellTypeList ();
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ public class CellNavigation
+ {
+ public string CellType { get; set; }
+ public ContentPage Page { get; set; }
+
+ public CellNavigation (string type, ContentPage page)
+ {
+ CellType = type;
+ Page = page;
+ }
+ }
+
+ public class CellTypeList : ListView
+ {
+ // TODO Add gallerys for ViewCell, ListView and TableView
+ public CellTypeList ()
+ {
+ var itemList = new List<CellNavigation> {
+ new CellNavigation ("TextCell List", new TextCellListPage ()),
+ new CellNavigation ("TextCell Table", new TextCellTablePage ()),
+ new CellNavigation ("ImageCell List", new ImageCellListPage ()),
+ new CellNavigation ("ImageCell Url List", new UrlImageCellListPage()),
+ new CellNavigation ("ImageCell Table", new ImageCellTablePage ()),
+ new CellNavigation ("SwitchCell List", new SwitchCellListPage ()),
+ new CellNavigation ("SwitchCell Table", new SwitchCellTablePage ()),
+ new CellNavigation ("EntryCell List", new EntryCellListPage ()),
+ new CellNavigation ("EntryCell Table", new EntryCellTablePage ()),
+ new CellNavigation ("ViewCell Image url table", new UrlImageViewCellListPage())
+ };
+
+ ItemsSource = itemList;
+
+ var template = new DataTemplate (typeof (TextCell));
+ template.SetBinding (TextCell.TextProperty, new Binding ("CellType"));
+
+ ItemTemplate = template;
+ ItemSelected += (s, e) => {
+ if (SelectedItem == null)
+ return;
+
+ var cellNav = (CellNavigation) e.SelectedItem;
+ Navigation.PushAsync (cellNav.Page);
+ SelectedItem = null;
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs
new file mode 100644
index 00000000..b70a9f82
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs
@@ -0,0 +1,54 @@
+using System.Linq;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public class EntryCellTest {
+ public string Label { get; set; }
+ public string Placeholder { get; set; }
+ public Color LabelColor { get; set; }
+ public Color PlaceholderColor { get; set; }
+
+ }
+
+ public class EntryCellListPage : ContentPage
+ {
+ public EntryCellListPage ()
+ {
+ Title = "EntryCell List Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var dataTemplate = new DataTemplate (typeof(EntryCell));
+ dataTemplate.SetBinding (EntryCell.LabelProperty, new Binding ("Label"));
+ dataTemplate.SetBinding (EntryCell.LabelColorProperty, new Binding ("LabelColor"));
+ dataTemplate.SetBinding (EntryCell.PlaceholderProperty, new Binding ("Placeholder"));
+
+ var label = new Label {
+ Text = "I have not been selected"
+ };
+
+ var listView = new ListView {
+ ItemsSource = Enumerable.Range (0, 100).Select (i => new EntryCellTest {
+ Label = "Label " + i,
+ LabelColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Placeholder = "Placeholder " + i,
+ PlaceholderColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ }),
+ ItemTemplate = dataTemplate
+ };
+
+ listView.ItemSelected += (sender, args) => {
+ label.Text = "I have been selected";
+ };
+
+
+
+ Content = new StackLayout { Children = { label, listView } };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs
new file mode 100644
index 00000000..c37dd441
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs
@@ -0,0 +1,85 @@
+namespace Xamarin.Forms.Controls
+{
+ public class EntryCellTablePage : ContentPage
+ {
+ public EntryCellTablePage ()
+ {
+ Title = "EntryCell Table Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ int timesEntered = 1;
+
+ var entryCell = new EntryCell { Label = "Enter text", Placeholder = "I am a placeholder" };
+ entryCell.Completed += (sender, args) => {
+ ((EntryCell)sender).Label = "Entered: " + timesEntered;
+ timesEntered++;
+ };
+
+ var tableSection = new TableSection ("Section One") {
+ new EntryCell { Label = "disabled", Placeholder = "disabled", IsEnabled = false },
+ new EntryCell { Label = "Text 2" },
+ new EntryCell { Label = "Text 3", Placeholder = "Placeholder 2" },
+ new EntryCell { Label = "Text 4" },
+ new EntryCell { Label = "Text 5", Placeholder = "Placeholder 3" },
+ new EntryCell { Label = "Text 6" },
+ new EntryCell { Label = "Text 7", Placeholder = "Placeholder 4" },
+ new EntryCell { Label = "Text 8" },
+ new EntryCell { Label = "Text 9", Placeholder = "Placeholder 5" },
+ new EntryCell { Label = "Text 10" },
+ new EntryCell { Label = "Text 11", Placeholder = "Placeholder 6" },
+ new EntryCell { Label = "Text 12" },
+ new EntryCell { Label = "Text 13", Placeholder = "Placeholder 7" },
+ new EntryCell { Label = "Text 14" },
+ new EntryCell { Label = "Text 15", Placeholder = "Placeholder 8" },
+ new EntryCell { Label = "Text 16" },
+ entryCell
+ };
+
+ var tableSectionTwo = new TableSection ("Section Two") {
+ new EntryCell { Label = "Text 17", Placeholder = "Placeholder 9" },
+ new EntryCell { Label = "Text 18" },
+ new EntryCell { Label = "Text 19", Placeholder = "Placeholder 10" },
+ new EntryCell { Label = "Text 20" },
+ new EntryCell { Label = "Text 21", Placeholder = "Placeholder 11" },
+ new EntryCell { Label = "Text 22" },
+ new EntryCell { Label = "Text 23", Placeholder = "Placeholder 12" },
+ new EntryCell { Label = "Text 24" },
+ new EntryCell { Label = "Text 25", Placeholder = "Placeholder 13" },
+ new EntryCell { Label = "Text 26" },
+ new EntryCell { Label = "Text 27", Placeholder = "Placeholder 14" },
+ new EntryCell { Label = "Text 28" },
+ new EntryCell { Label = "Text 29", Placeholder = "Placeholder 15" },
+ new EntryCell { Label = "Text 30" },
+ new EntryCell { Label = "Text 31", Placeholder = "Placeholder 16" },
+ new EntryCell { Label = "Text 32" },
+ };
+
+ var keyboards = new TableSection ("Keyboards") {
+ new EntryCell { Label = "Chat", Keyboard = Keyboard.Chat },
+ new EntryCell { Label = "Default", Keyboard = Keyboard.Default },
+ new EntryCell { Label = "Email", Keyboard = Keyboard.Email },
+ new EntryCell { Label = "Numeric", Keyboard = Keyboard.Numeric },
+ new EntryCell { Label = "Telephone", Keyboard = Keyboard.Telephone },
+ new EntryCell { Label = "Text", Keyboard = Keyboard.Text },
+ new EntryCell { Label = "Url", Keyboard = Keyboard.Url }
+ };
+
+ var root = new TableRoot ("Text Cell table") {
+ tableSection,
+ tableSectionTwo,
+ keyboards
+ };
+
+ var table = new TableView {
+ Root = root
+ };
+
+ Content = table;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs
new file mode 100644
index 00000000..1f58a339
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public class ImageCellTest {
+ public object Text { get; set; }
+ public object TextColor { get; set; }
+ public object Detail { get; set; }
+ public object DetailColor { get; set; }
+ public object Image { get; set; }
+ }
+
+ public class ImageCellListPage : ContentPage
+ {
+
+ public ImageCellListPage ()
+ {
+ Title = "ImageCell List Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var dataTemplate = new DataTemplate (typeof (ImageCell));
+ var stringToImageSourceConverter = new GenericValueConverter (
+ obj => new FileImageSource {
+ File = (string) obj
+ }
+ );
+
+ dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
+ dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
+ dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
+ dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
+ dataTemplate.SetBinding (ImageCell.ImageSourceProperty, new Binding ("Image", converter: stringToImageSourceConverter));
+
+ Random rand = new Random(250);
+
+ var albums = new [] {
+ "crimsonsmall.jpg",
+ "oasissmall.jpg",
+ "cover1small.jpg"
+ };
+
+ var label = new Label { Text = "I have not been selected" };
+
+ var listView = new ListView {
+ AutomationId = "ImageCellListView",
+ ItemsSource = Enumerable.Range (0, 100).Select (i => new ImageCellTest {
+ Text = "Text " + i,
+ TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Detail = "Detail " + i,
+ DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Image = albums[rand.Next(0,3)]
+ }),
+ ItemTemplate = dataTemplate
+ };
+
+ listView.ItemSelected += (sender, args) => label.Text = "I was selected";
+
+ Content = new StackLayout { Children = { label, listView } };
+
+ }
+ }
+
+ public class UrlImageCellListPage : ContentPage
+ {
+ public UrlImageCellListPage()
+ {
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var dataTemplate = new DataTemplate (typeof (ImageCell));
+ var stringToImageSourceConverter = new GenericValueConverter (
+ obj => new UriImageSource() {
+ Uri = new Uri ((string) obj)
+ });
+
+ dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
+ dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
+ dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
+ dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
+ dataTemplate.SetBinding (ImageCell.ImageSourceProperty,
+ new Binding ("Image", converter: stringToImageSourceConverter));
+
+ var albums = new List<string> ();
+ for (int i = 0; i < 30; i++) {
+ albums.Add (string.Format ("http://cdn.instructables.com/FCP/9TOJ/GCJ0ZQV5/FCP9TOJGCJ0ZQV5.MEDIUM.jpg?ticks={0}",i ));
+ }
+
+
+ var random = new Random();
+ var label = new Label { Text = "I have not been selected" };
+
+ var listView = new ListView {
+ AutomationId = "ImageUrlCellListView",
+ ItemsSource = Enumerable.Range (0, 300).Select (i => new ImageCellTest {
+ Text = "Text " + i,
+ TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Detail = "Detail " + i,
+ DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Image = albums [random.Next (0, albums.Count - 1)]
+ }),
+ ItemTemplate = dataTemplate
+ };
+
+ listView.ItemSelected += (sender, args) => label.Text = "I was selected";
+
+ Content = new StackLayout { Children = { label, listView } };
+
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs
new file mode 100644
index 00000000..2b941bfd
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs
@@ -0,0 +1,68 @@
+namespace Xamarin.Forms.Controls
+{
+ public class ImageCellTablePage : ContentPage
+ {
+
+ public ImageCellTablePage ()
+ {
+ Title = "ImageCell Table Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var tableSection = new TableSection ("Section One") {
+ new ImageCell { Text = "Text 1", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 2", Detail = "Detail 1", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 3", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 4", Detail = "Detail 2", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 5", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ new ImageCell { Text = "Text 6", Detail = "Detail 3", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ new ImageCell { Text = "Text 7", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 8", Detail = "Detail 4", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 9", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 10", Detail = "Detail 5", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 11", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ new ImageCell { Text = "Text 12", Detail = "Detail 6", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ };
+
+ ImageCell imageCell = null;
+ imageCell = new ImageCell {
+ Text = "not tapped",
+ ImageSource = "oasis.jpg",
+ Command = new Command(()=>{
+ imageCell.Text = "tapped";
+ (imageCell.ImageSource as FileImageSource).File = "crimson.jpg";
+ })
+ };
+ var tableSectionTwo = new TableSection ("Section Two") {
+ new ImageCell { Text = "Text 13", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 14", Detail = "Detail 7", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 15", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 16", Detail = "Detail 8", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 17", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ new ImageCell { Text = "Text 18", Detail = "Detail 9", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ new ImageCell { Text = "Text 19", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 20", Detail = "Detail 10", ImageSource = new FileImageSource { File = "crimson.jpg" } },
+ new ImageCell { Text = "Text 21", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 22", Detail = "Detail 11", ImageSource = new FileImageSource { File = "cover1.jpg" } },
+ new ImageCell { Text = "Text 23", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ new ImageCell { Text = "Text 24", Detail = "Detail 12", ImageSource = new FileImageSource { File = "oasis.jpg" } },
+ imageCell,
+ };
+
+ var root = new TableRoot ("Text Cell table") {
+ tableSection,
+ tableSectionTwo
+ };
+
+ var table = new TableView {
+ Root = root,
+ };
+
+ Content = table;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs
new file mode 100644
index 00000000..5973ebab
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ProductCellView : StackLayout
+ {
+ Label _timeLabel;
+ Label _brandLabel;
+ StackLayout _stack;
+ public ProductCellView (string text)
+ {
+ _stack = new StackLayout ();
+ _brandLabel = new Label {Text = "BrandLabel", HorizontalTextAlignment = TextAlignment.Center};
+ _stack.Children.Add (_brandLabel);
+
+
+ var frame = new Frame {
+ Content = _stack,
+ BackgroundColor = Device.OnPlatform (iOS: new Color (1), Android: new Color (0.2), WinPhone: new Color (0.2))
+ };
+ _timeLabel = new Label {
+ Text = text
+ };
+ Children.Add (_timeLabel);
+ Children.Add (frame);
+ Padding = new Size (20, 20);
+ }
+ }
+}
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
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs
new file mode 100644
index 00000000..a0deb8e6
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs
@@ -0,0 +1,65 @@
+namespace Xamarin.Forms.Controls
+{
+ public class SwitchCellTablePage : ContentPage
+ {
+ public SwitchCellTablePage ()
+ {
+ Title = "SwitchCell Table Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var tableSection = new TableSection ("Section One") {
+ new SwitchCell { Text = "text 1", On = true },
+ new SwitchCell { Text = "text 2" },
+ new SwitchCell { Text = "text 3", On = true },
+ new SwitchCell { Text = "text 4", On = false },
+ new SwitchCell { Text = "text 5", On = true },
+ new SwitchCell { Text = "text 6" },
+ new SwitchCell { Text = "text 7", On = true },
+ new SwitchCell { Text = "text 8", On = false },
+ new SwitchCell { Text = "text 9", On = true },
+ new SwitchCell { Text = "text 10" },
+ new SwitchCell { Text = "text 11", On = true },
+ new SwitchCell { Text = "text 12", On = false },
+ new SwitchCell { Text = "text 13", On = true },
+ new SwitchCell { Text = "text 14" },
+ new SwitchCell { Text = "text 15", On = true },
+ new SwitchCell { Text = "text 16", On = false },
+ };
+
+ var tableSectionTwo = new TableSection ("Section Two") {
+ new SwitchCell { Text = "text 17", On = true },
+ new SwitchCell { Text = "text 18" },
+ new SwitchCell { Text = "text 19", On = true },
+ new SwitchCell { Text = "text 20", On = false },
+ new SwitchCell { Text = "text 21", On = true },
+ new SwitchCell { Text = "text 22" },
+ new SwitchCell { Text = "text 23", On = true },
+ new SwitchCell { Text = "text 24", On = false },
+ new SwitchCell { Text = "text 25", On = true },
+ new SwitchCell { Text = "text 26" },
+ new SwitchCell { Text = "text 27", On = true },
+ new SwitchCell { Text = "text 28", On = false },
+ new SwitchCell { Text = "text 29", On = true },
+ new SwitchCell { Text = "text 30" },
+ new SwitchCell { Text = "text 31", On = true },
+ new SwitchCell { Text = "text 32", On = false },
+ };
+
+ var root = new TableRoot ("Text Cell table") {
+ tableSection,
+ tableSectionTwo
+ };
+
+ var table = new TableView {
+ Root = root,
+ };
+
+ Content = table;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs
new file mode 100644
index 00000000..fbd5e265
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs
@@ -0,0 +1,48 @@
+using System.Linq;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public class TextCellTest {
+ public object Text { get; set; }
+ public object TextColor { get; set; }
+ public object Detail { get; set; }
+ public object DetailColor { get; set; }
+ }
+
+ public class TextCellListPage : ContentPage
+ {
+ public TextCellListPage ()
+ {
+ Title = "TextCell List Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var label = new Label { Text = "Not Selected" };
+
+ var dataTemplate = new DataTemplate (typeof (TextCell));
+ dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text"));
+ dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor"));
+ dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail"));
+ dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor"));
+
+ var listView = new ListView {
+ ItemsSource = Enumerable.Range (0, 100).Select (i => new TextCellTest {
+ Text = "Text " + i,
+ TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Detail = "Detail " + i,
+ DetailColor = i % 2 == 0 ? Color.Red : Color.Blue
+ }),
+ ItemTemplate = dataTemplate
+ };
+
+ listView.ItemSelected += (sender, args) => { label.Text = "I was selected"; };
+
+ Content = new StackLayout { Children = { label, listView } };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs
new file mode 100644
index 00000000..b9cc0cf3
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs
@@ -0,0 +1,58 @@
+namespace Xamarin.Forms.Controls
+{
+ public class TextCellTablePage : ContentPage
+ {
+
+ public TextCellTablePage ()
+ {
+ Title = "TextCell Table Gallery - Legacy";
+
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var tableSection = new TableSection ("Section One") {
+ new TextCell { Text = "Text 1" },
+ new TextCell { Text = "Text 2", Detail = "Detail 1" },
+ new TextCell { Text = "Text 3" },
+ new TextCell { Text = "Text 4", Detail = "Detail 2" },
+ new TextCell { Text = "Text 5" },
+ new TextCell { Text = "Text 6", Detail = "Detail 3" },
+ new TextCell { Text = "Text 7" },
+ new TextCell { Text = "Text 8", Detail = "Detail 4" },
+ new TextCell { Text = "Text 9" },
+ new TextCell { Text = "Text 10", Detail = "Detail 5" },
+ new TextCell { Text = "Text 11" },
+ new TextCell { Text = "Text 12", Detail = "Detail 6" }
+ };
+
+ var tableSectionTwo = new TableSection ("Section Two") {
+ new TextCell { Text = "Text 13" },
+ new TextCell { Text = "Text 14", Detail = "Detail 7" },
+ new TextCell { Text = "Text 15" },
+ new TextCell { Text = "Text 16", Detail = "Detail 8" },
+ new TextCell { Text = "Text 17" },
+ new TextCell { Text = "Text 18", Detail = "Detail 9" },
+ new TextCell { Text = "Text 19" },
+ new TextCell { Text = "Text 20", Detail = "Detail 10" },
+ new TextCell { Text = "Text 21" },
+ new TextCell { Text = "Text 22", Detail = "Detail 11" },
+ new TextCell { Text = "Text 23" },
+ new TextCell { Text = "Text 24", Detail = "Detail 12" }
+ };
+
+ var root = new TableRoot ("Text Cell table") {
+ tableSection,
+ tableSectionTwo
+ };
+
+ var table = new TableView {
+ Root = root,
+ };
+
+ Content = table;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/UnEvenViewCellGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/UnEvenViewCellGallery.cs
new file mode 100644
index 00000000..00c2980f
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/UnEvenViewCellGallery.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class UnevenViewCellGallery : ContentPage
+ {
+ public UnevenViewCellGallery ()
+ {
+ Title = "UnevenViewCell Gallery - Legacy";
+
+ var map = MapGallery.MakeMap ();
+ map.HasScrollEnabled = false;
+
+ Content = new TableView {
+ RowHeight = 150,
+ HasUnevenRows = true,
+ Root = new TableRoot {
+ new TableSection ("Testing") {
+ new ViewCell {View = map, Height = 250},
+ new ViewCell {View = new ProductCellView ("1 day")},
+ new ViewCell {View = new ProductCellView ("2 days")},
+ new ViewCell {View = new ProductCellView ("3 days")},
+ new ViewCell {View = new ProductCellView ("4 days")},
+ new ViewCell {View = new ProductCellView ("5 days")}
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs
new file mode 100644
index 00000000..099a786a
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ViewCellGallery : ContentPage
+ {
+ public ViewCellGallery ()
+ {
+ Title = "ViewCell Gallery - Legacy";
+
+ Content = new TableView {
+ RowHeight = 150,
+ Root = new TableRoot {
+ new TableSection ("Testing") {
+ new ViewCell {View = new ProductCellView ("0")},
+ new ViewCell {View = new ProductCellView ("1")},
+ new ViewCell {View = new ProductCellView ("2")},
+ new ViewCell {View = new ProductCellView ("3")},
+ new ViewCell {View = new ProductCellView ("4")}
+ }
+ }
+ };
+ }
+ }
+
+ public class UrlImageViewCellListPage : ContentPage
+ {
+ public UrlImageViewCellListPage()
+ {
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var stringToImageSourceConverter = new GenericValueConverter (
+ obj => new UriImageSource() {
+ Uri = new Uri ((string) obj)
+ });
+
+ var dataTemplate = new DataTemplate (() => {
+ var cell = new ViewCell();
+
+ var image = new Image();
+ image.SetBinding (Image.SourceProperty, new Binding ("Image", converter: stringToImageSourceConverter));
+ image.WidthRequest = 160;
+ image.HeightRequest = 160;
+
+ var text = new Label();
+ text.SetBinding (Label.TextProperty, new Binding ("Text"));
+ text.SetBinding (Label.TextColorProperty, new Binding ("TextColor"));
+
+ cell.View = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ image,
+ text
+ }
+ };
+
+ return cell;
+ });
+
+ var albums = new[] {
+ "https://evolve.xamarin.com/images/sessions/joseph-mayo-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/jon-skeet-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/rachel-reese-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/mike-james-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/daniel-cazzulino-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/michael-hutchinson-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/laurent-bugnion-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/craig-dunn-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/charles-petzold-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/jason-smith-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/frank-krueger-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/james-clancey-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/daniel-plaisted-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/jesse-liberty-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/miguel-de-icaza-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/rene-ruppert-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/brent-schooley-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/adrian-stevens-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/rodrigo-kumpera-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/alex-corrado-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/jonathan-pryor-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/michael-stonis-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/jeremie-laval-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/james-montemagno-icon.jpg",
+ "https://evolve.xamarin.com/images/sessions/brett-duncavage-icon.jpg"
+ };
+
+ var label = new Label { Text = "I have not been selected" };
+
+ var listView = new ListView {
+ ItemsSource = Enumerable.Range (0, albums.Length).Select (i => new {
+ Text = "Text " + i,
+ TextColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Detail = "Detail " + i,
+ DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
+ Image = albums[i]
+ }),
+ ItemTemplate = dataTemplate
+ };
+
+ listView.ItemSelected += (sender, args) => label.Text = "I was selected";
+
+ Content = new StackLayout { Children = { label, listView } };
+
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ClipToBoundsGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ClipToBoundsGallery.cs
new file mode 100644
index 00000000..b7cdd8fb
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ClipToBoundsGallery.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ClipToBoundsGallery : ContentPage
+ {
+ public ClipToBoundsGallery ()
+ {
+ var child1 = new BoxView { Color = Color.Red };
+ var child2 = new BoxView { Color = Color.Blue };
+ var button = new Button { Text = "Clip", BackgroundColor = Color.Green };
+
+ Padding = new Thickness (55);
+ var layout = new AbsoluteLayout {
+ Children = {
+ {child1, new Rectangle (-50, 0, 100, 100)},
+ {child2, new Rectangle (0, -50, 100, 100)},
+ {button, new Rectangle (1.0, 0.5, 100, 100), AbsoluteLayoutFlags.PositionProportional}
+ }
+ };
+
+ button.Clicked += (sender, args) => layout.IsClippedToBounds = !layout.IsClippedToBounds;
+
+ Content = layout;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs b/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs
new file mode 100644
index 00000000..32eb2a19
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls.GalleryPages
+{
+ internal class ControlTemplatePage : ContentPage
+ {
+ [Preserve (AllMembers = true)]
+ class MyLayout : StackLayout
+ {
+ public MyLayout ()
+ {
+ Children.Add (new Label {Text = "Before"});
+ Children.Add (new ContentPresenter ());
+ Children.Add (new Label {Text = "After"});
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ class MyOtherLayout : StackLayout
+ {
+ public MyOtherLayout ()
+ {
+ Children.Add (new Entry {Text = "Before"});
+ Children.Add (new ContentPresenter ());
+ Children.Add (new Entry {Text = "After"});
+ }
+ }
+
+ public ControlTemplatePage ()
+ {
+ var button = new Button { Text = "Replace Template" };
+ var content = new ContentView {
+ Content = button,
+ ControlTemplate = new ControlTemplate (typeof (MyLayout))
+ };
+
+ button.Clicked += (sender, args) => {
+ content.ControlTemplate = new ControlTemplate (typeof (MyOtherLayout));
+ };
+
+ Content = content;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml b/Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml
new file mode 100644
index 00000000..38ad4753
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Controls.GalleryPages.ControlTemplateXamlPage">
+ <ContentPage.Resources>
+ <ResourceDictionary>
+ <ControlTemplate x:Key="ViewTemplate">
+ <StackLayout>
+ <Label Text="{TemplateBinding Parent.AboveText}" />
+ <ContentPresenter />
+ <Label Text="Below" />
+ </StackLayout>
+ </ControlTemplate>
+ <Style TargetType="ContentView">
+ <Style.Setters>
+ <Setter Property="ControlTemplate" Value="{StaticResource ViewTemplate}" />
+ </Style.Setters>
+ </Style>
+ </ResourceDictionary>
+ </ContentPage.Resources>
+ <ContentView>
+ <Label Text="I R CONTENT" />
+ </ContentView>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml.cs b/Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml.cs
new file mode 100644
index 00000000..b329ea12
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ControlTemplateXamlPage.xaml.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Controls.GalleryPages
+{
+ public partial class ControlTemplateXamlPage : ContentPage
+ {
+ public static readonly BindableProperty AboveTextProperty =
+ BindableProperty.Create (nameof (AboveText), typeof (string), typeof (ControlTemplateXamlPage), null);
+
+ public string AboveText
+ {
+ get { return (string)GetValue (AboveTextProperty); }
+ set { SetValue (AboveTextProperty, value); }
+ }
+
+ public ControlTemplateXamlPage ()
+ {
+ BindingContext = new {
+ Text = "Testing 123"
+ };
+ this.SetBinding (AboveTextProperty, "Text");
+ InitializeComponent ();
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs b/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs
new file mode 100644
index 00000000..910c1af7
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/DisposeGallery.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class DisposeGallery : ContentPage
+ {
+ public DisposeGallery ()
+ {
+ var disposePage = new DisposePage ();
+
+ var pushButton = new Button {Text = "Push disposable page"};
+ var pushModalButton = new Button {Text = "PushModal disposable page"};
+
+ pushButton.Clicked += (sender, args) => {
+ disposePage.PopAction = () => Navigation.PopAsync ();
+ Navigation.PushAsync (disposePage);
+ };
+ pushModalButton.Clicked += (sender, args) => {
+ disposePage.PopAction = () => Navigation.PopModalAsync ();
+ Navigation.PushModalAsync (disposePage);
+ };
+
+ var appearingLabel = new Label {Text = "Appearing not sent"};
+ var disappearingLabel = new Label {Text = "Disappearing not sent"};
+
+ var disposedPageLabel = new Label {Text = "Page renderer not yet disposed"};
+ var disposedLabelsLabel = new Label {Text = "Number of disposed labels: 0"};
+
+ disposePage.Appearing += (sender, args) => appearingLabel.Text = "Appearing sent";
+ disposePage.Disappearing += (sender, args) => disappearingLabel.Text = "Disappearing sent";
+ disposePage.RendererDisposed += (sender, args) => {
+ disposedPageLabel.Text = "Page renderer disposed";
+ // give some time for this to propogate
+ Device.StartTimer (TimeSpan.FromSeconds (1), () => {
+ disposedLabelsLabel.Text = "Number of disposed labels: " + disposePage.DisposedLabelCount;
+ return false;
+ });
+
+ };
+
+ Content = new StackLayout {
+ Padding = new Thickness (20),
+ Children = {
+ pushButton,
+ pushModalButton,
+ appearingLabel,
+ disappearingLabel,
+ disposedLabelsLabel,
+ disposedPageLabel
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/EditableList.cs b/Xamarin.Forms.Controls/GalleryPages/EditableList.cs
new file mode 100644
index 00000000..2a7b1a85
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/EditableList.cs
@@ -0,0 +1,116 @@
+using System.Collections.ObjectModel;
+using System.Windows.Input;
+using System.Linq;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class MessagesViewModel : ViewModelBase
+ {
+ public MessagesViewModel()
+ {
+ Messages = new ObservableCollection<MessageViewModel> (Enumerable.Range (0, 100).Select (i => {
+ return new MessageViewModel { Subject = "Subject Line " + i, MessagePreview = "Lorem ipsum dolorem monkeys bonkers " + i };
+ }));
+
+ MessagingCenter.Subscribe<MessageViewModel, MessageViewModel> (this, "DeleteMessage", (vm, vm2) => {
+ Messages.Remove (vm);
+ });
+ }
+
+ public ObservableCollection<MessageViewModel> Messages
+ {
+ get;
+ private set;
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class MessageViewModel : ViewModelBase
+ {
+ public MessageViewModel()
+ {
+ Delete = new Command (() => MessagingCenter.Send (this, "DeleteMessage", this));
+ Move = new Command (() => MessagingCenter.Send (this, "MoveMessage", this));
+ }
+
+ public string Subject
+ {
+ get;
+ set;
+ }
+
+ public string MessagePreview
+ {
+ get;
+ set;
+ }
+
+ public ICommand Delete
+ {
+ get;
+ private set;
+ }
+
+ public ICommand Move
+ {
+ get;
+ private set;
+ }
+ }
+
+ internal class ContextActionsGallery : ContentPage
+ {
+ class MessageCell : TextCell
+ {
+ public MessageCell()
+ {
+ this.SetBinding (TextProperty, "Subject");
+ this.SetBinding (DetailProperty, "MessagePreview");
+
+ var delete = new MenuItem { Text = "Delete", IsDestructive = true };
+ delete.SetBinding (MenuItem.CommandProperty, "Delete");
+
+ var mark = new MenuItem { Text = "Mark", Icon = "calculator.png" };
+ var move = new MenuItem { Text = "Move" };
+
+ //move.Clicked += async (sender, e) => await Navigation.PopAsync();
+
+ ContextActions.Add (mark);
+ ContextActions.Add (delete);
+ ContextActions.Add (move);
+
+ var clear = new MenuItem { Text = "Clear Items" };
+ clear.Clicked += (sender, args) => ContextActions.Clear();
+ ContextActions.Add (clear);
+ }
+ }
+
+ public ContextActionsGallery (bool tableView = false)
+ {
+ BindingContext = new MessagesViewModel();
+
+ View list;
+ if (!tableView) {
+ list = new ListView();
+ list.SetBinding (ListView.ItemsSourceProperty, "Messages");
+ ((ListView)list).ItemTemplate = new DataTemplate (typeof (MessageCell));
+ } else {
+ var section = new TableSection();
+ section.Add (new TextCell { Text = "I have no ContextActions", Detail = "Sup" });
+ foreach (var msg in ((MessagesViewModel) BindingContext).Messages) {
+ section.Add (new MessageCell { BindingContext = msg });
+ }
+
+ list = new TableView();
+ ((TableView)list).Root = new TableRoot { section };
+ }
+
+ Content = new StackLayout {
+ Children = {
+ new Label { Text = "Email" },
+ list
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/EditorGallery.cs b/Xamarin.Forms.Controls/GalleryPages/EditorGallery.cs
new file mode 100644
index 00000000..fde03236
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/EditorGallery.cs
@@ -0,0 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class EditorGallery : ContentPage
+ {
+ public EditorGallery ()
+ {
+ var cellTemplate = new DataTemplate (typeof (TextCell));
+ cellTemplate.SetBinding (TextCell.TextProperty, new Binding ("Title"));
+
+ var list = new ListView {
+ ItemsSource = new ContentPage [] {
+ new EditorGalleryPage ("Default Keyboard", Keyboard.Default),
+ new EditorGalleryPage ("Chat Keyboard", Keyboard.Chat),
+ new EditorGalleryPage ("Text Keyboard", Keyboard.Text),
+ new EditorGalleryPage ("Url Keyboard", Keyboard.Url),
+ new EditorGalleryPage ("Numeric Keyboard", Keyboard.Numeric),
+ new EditableEditorPage ("Enabled", true),
+ new EditableEditorPage ("Disabled", false),
+
+ },
+ ItemTemplate = cellTemplate
+ };
+
+ list.ItemSelected += (sender, arg) => {
+ if (list.SelectedItem != null) {
+ Navigation.PushAsync ((ContentPage)list.SelectedItem);
+ list.SelectedItem = null;
+ }
+ };
+
+ Content = list;
+ }
+ }
+
+ internal class EditableEditorPage : ContentPage
+ {
+ public EditableEditorPage (string title, bool enabled)
+ {
+ Title = "Editable " + enabled.ToString ();
+ Padding = new Thickness (20);
+ var editor = new Editor {
+ Text = Title,
+ IsEnabled = enabled,
+ HeightRequest = 75,
+ };
+
+ var disableButton = new Button {
+ Text = "Disable Editor",
+ };
+
+ var enableButton = new Button {
+ Text = "Enable Editor",
+ };
+
+ disableButton.Clicked += (object sender, EventArgs e) => {
+ editor.IsEnabled = false;
+ };
+
+ enableButton.Clicked += (object sender, EventArgs e) => {
+ editor.IsEnabled = true;
+ };
+
+ Content = new StackLayout {
+ Children = { editor, disableButton, enableButton, }
+ };
+ }
+ }
+
+ public class EditorGalleryPage : ContentPage
+ {
+ public EditorGalleryPage (string title, Keyboard keyboard)
+ {
+ Title = title;
+ BackgroundColor = Color.Red;
+ Padding = new Thickness (20);
+
+ var label = new Label {
+ Text = "Nothing entered"
+ };
+
+ var label2 = new Label {
+ Text = ""
+ };
+
+ var editor = new Editor {
+ HeightRequest = 75,
+ Keyboard = keyboard,
+ Text = "PlaceHolder",
+ };
+
+ editor.Completed += (sender, e) => {
+ label.Text = "Entered : " + editor.Text;
+ };
+
+ editor.TextChanged += (sender, e) => {
+ label2.Text += "x";
+ };
+
+ var unfocus = new Button {
+ Text = "Unfocus",
+ };
+
+ var focus = new Button {
+ Text = "Focus",
+ };
+
+ unfocus.Clicked += (sender, e) => {
+ editor.Unfocus();
+ };
+
+ focus.Clicked += (sender, e) => {
+ editor.Focus();
+ };
+
+ Content = new StackLayout {
+ Children = {
+ label,
+ label2,
+ editor,
+ focus,
+ unfocus,
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/EntryGallery.cs b/Xamarin.Forms.Controls/GalleryPages/EntryGallery.cs
new file mode 100644
index 00000000..5fcf7b83
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/EntryGallery.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class EntryGallery : ContentPage
+ {
+ public EntryGallery ()
+ {
+ var label = new Label { Text = "Enter something in Normal" };
+ var label2 = new Label { Text = "No typing has happened in Normal yet" };
+ var normal = new Entry { Placeholder = "Normal" };
+ var password = new Entry { Placeholder = "Password" };
+ var numericPassword = new Entry { Placeholder = "Numeric Password" };
+ var activation = new Entry { Placeholder = "Activation" };
+ var disabled = new Entry { Placeholder = "Disabled" };
+ var transparent = new Entry { Placeholder = "Transparent" };
+
+ var isFocusedlabel = new Label {
+ Text = "Focus an Entry"
+ };
+
+ var changeKeyboardType = new Entry {
+ Placeholder = "Keyboard.Default",
+ Keyboard = Keyboard.Default
+ };
+
+ changeKeyboardType.Completed += (sender, e) => {
+ changeKeyboardType.Placeholder = "Keyboard.Numeric";
+ changeKeyboardType.Keyboard = Keyboard.Numeric;
+ };
+
+ normal.TextChanged += (s, e) => label2.Text = "You typed in normal";
+
+ normal.Focused += (s, e) => isFocusedlabel.Text = "Normal Focused";
+ normal.Completed += (s, e) => { label.Text = normal.Text; };
+ password.Focused += (s, e) => isFocusedlabel.Text = "Password Focused";
+ numericPassword.Focused += (s, e) => isFocusedlabel.Text = "Numeric Password Focused";
+ activation.Focused += (s, e) => isFocusedlabel.Text = "Activation Focused";
+ disabled.Focused += (s, e) => isFocusedlabel.Text = "Disabled Focused";
+ transparent.Focused += (s, e) => isFocusedlabel.Text = "Transparent Focused";
+ changeKeyboardType.Focused += (s, e) => isFocusedlabel.Text = "Keyboard.Default Focused";
+
+ var toggleColorButton = new Button { Text = "Toggle Text Color" };
+ var changeSecureButton = new Button { Text = "Toggle Secure" };
+ var changePlaceholderButton = new Button { Text = "Change Placeholder" };
+ var focusNormalButton = new Button { Text = "Focus First" };
+
+ transparent.Opacity = 0.5;
+ password.IsPassword = true;
+ numericPassword.IsPassword = true;
+ numericPassword.Keyboard = Keyboard.Numeric;
+ activation.Completed += (sender, e) => activation.Text = "Activated";
+ disabled.IsEnabled = false;
+
+ toggleColorButton.Clicked += (sender, e) => {
+ if (normal.TextColor == Color.Default) {
+ normal.TextColor = Color.Red;
+ password.TextColor = Color.Red;
+ numericPassword.TextColor = Color.Red;
+ } else {
+ normal.TextColor = Color.Default;
+ password.TextColor = Color.Default;
+ numericPassword.TextColor = Color.Default;
+ }
+ };
+
+ changeSecureButton.Clicked += (sender, e) => {
+ password.IsPassword = !password.IsPassword;
+ numericPassword.IsPassword = !numericPassword.IsPassword;
+ };
+
+ int i = 1;
+ changePlaceholderButton.Clicked += (sender, e) => { normal.Placeholder = "Placeholder " + i++.ToString (); };
+
+ focusNormalButton.Clicked += (sender, args) => normal.Focus ();
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Padding = new Thickness (80),
+ Children = {
+ label,
+ label2,
+ normal,
+ password,
+ numericPassword,
+ disabled,
+ isFocusedlabel,
+ activation,
+ transparent,
+ changeKeyboardType,
+ toggleColorButton,
+ changeSecureButton,
+ changePlaceholderButton,
+ focusNormalButton,
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs b/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs
new file mode 100644
index 00000000..ee7c1822
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class FrameGallery : ContentPage
+ {
+ readonly StackLayout _stack;
+
+ public FrameGallery ()
+ {
+ Content = _stack = new StackLayout { Padding = new Size (20, 20) };
+
+ //BackgroundColor = new Color (0.5, 0.5, 0.5);
+ BackgroundColor = Color.FromHex ("#8a2be2");
+ //BackgroundColor = Color.Aqua;
+
+ var frame = new Frame {
+ Content = new Button {
+ Text = "Framous!"
+ },
+ BackgroundColor = Device.OnPlatform (iOS: new Color (1), Android: new Color (0), WinPhone: new Color (0)),
+ VerticalOptions = LayoutOptions.FillAndExpand
+ };
+
+ _stack.Children.Add (frame);
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/GridGallery.cs b/Xamarin.Forms.Controls/GalleryPages/GridGallery.cs
new file mode 100644
index 00000000..d786a81b
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/GridGallery.cs
@@ -0,0 +1,174 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+
+ public class GridGallery : ContentPage
+ {
+ public GridGallery ()
+ {
+ var layout = new StackLayout {
+ Orientation = StackOrientation.Vertical
+ };
+
+ //ColumnTypes
+ layout.Children.Add (new Label { Text = "Column Types:" });
+ var grid = new Grid {
+ ColumnDefinitions = {
+ new ColumnDefinition { Width = 80 },
+ new ColumnDefinition (),
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }
+ },
+ BackgroundColor = Color.FromRgb (0xee, 0xee, 0xee)
+ };
+
+ grid.Children.Add (new Label {
+ Text = "Absolute Width",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, 0, 0);
+ grid.Children.Add (new Label {
+ Text = "Auto Width",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, 1, 0);
+ grid.Children.Add (new Label {
+ Text = "Star",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, 2, 0);
+ layout.Children.Add (grid);
+
+ //Star
+ layout.Children.Add (new Label { Text = "Star Columns:" });
+ grid = new Grid {
+ ColumnDefinitions = {
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
+ },
+ BackgroundColor = Color.FromRgb (0xee, 0xee, 0xee),
+ ColumnSpacing = 0,
+ RowSpacing = 0,
+ };
+
+ grid.Children.Add (new Label {
+ Text = "*",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, 0, 0);
+ grid.Children.Add (new Label {
+ Text = "**",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, 1, 0);
+ grid.Children.Add (new Label {
+ Text = "***",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, 2, 0);
+ layout.Children.Add (grid);
+
+ //Alignment
+ layout.Children.Add (new Label { Text = "Alignment:" });
+ grid = new Grid {
+ ColumnDefinitions = {
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ },
+ BackgroundColor = Color.FromRgb (0xee, 0xee, 0xee)
+ };
+
+ grid.Children.Add (new Label {
+ Text = "Right",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ HorizontalOptions = LayoutOptions.End,
+ }, 0, 0);
+ grid.Children.Add (new Label {
+ Text = "Center",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ HorizontalOptions = LayoutOptions.Center,
+
+ }, 1, 0);
+ grid.Children.Add (new Label {
+ Text = "Left",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ HorizontalOptions = LayoutOptions.Start,
+ }, 2, 0);
+ grid.Children.Add (new Label {
+ Text = "Fill",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ HorizontalOptions = LayoutOptions.Fill,
+ }, 3, 0);
+ layout.Children.Add (grid);
+
+ //Spanning
+ layout.Children.Add (new Label { Text = "Spans:" });
+ grid = new Grid {
+ ColumnDefinitions = {
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
+ },
+ BackgroundColor = Color.FromRgb (0xee, 0xee, 0xee),
+ ColumnSpacing = 0,
+ RowSpacing = 0
+ };
+
+ for (var i=0;i<5;i++)
+ for (var j=0;j<5;j++)
+ grid.Children.Add (new Label {
+ Text = "Unit",
+ BackgroundColor = Color.FromRgb (0xcc, 0xcc, 0xcc),
+ }, i, j);
+
+
+ grid.Children.Add (new Label {
+ Text = "Spanning 4 columns",
+ BackgroundColor = Color.Red,
+ }, 0,4,0,1);
+ grid.Children.Add (new Label {
+ Text = "Spanning 3 rows",
+ BackgroundColor = Color.Gray,
+ }, 4,5, 0,3);
+ grid.Children.Add (new Label {
+ Text = "a block 3x3",
+ BackgroundColor = Color.Green,
+ }, 1,4,1,4);
+ layout.Children.Add (grid);
+
+
+ //Change Width
+ var col0 = new ColumnDefinition { Width = 40 };
+ var col1 = new ColumnDefinition { Width = 80 };
+
+ grid = new Grid {
+ ColumnDefinitions = new ColumnDefinitionCollection {
+ col0, col1
+ }
+ };
+
+ grid.Children.Add (new BoxView { BackgroundColor = Color.Red });
+ grid.Children.Add (new BoxView { BackgroundColor = Color.Blue },1,0);
+
+ layout.Children.Add (grid);
+ layout.Children.Add (new Button {
+ Text = "ChangeWidth",
+ Command = new Command (()=>{
+ var t = col0.Width;
+ col0.Width = col1.Width;
+ col1.Width = t;
+ })
+ });
+
+ Content = new ScrollView {
+ Content = layout,
+ };
+
+
+
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/GroupedListActionsGallery.cs b/Xamarin.Forms.Controls/GalleryPages/GroupedListActionsGallery.cs
new file mode 100644
index 00000000..3d8b85c9
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/GroupedListActionsGallery.cs
@@ -0,0 +1,282 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class GroupedListActionsGallery
+ : ContentPage
+ {
+ class Group
+ : ObservableList<GroupAction>, INotifyPropertyChanged
+ {
+ public Group (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+
+ Name = name;
+ ShortName = Name[0].ToString();
+ }
+
+ string _name;
+ string _shortName;
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public string Name
+ {
+ get { return _name; }
+ set
+ {
+ if (_name == value)
+ return;
+
+ _name = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public string ShortName
+ {
+ get { return _shortName; }
+ set
+ {
+ if (_shortName == value)
+ return;
+
+ _shortName = value;
+ OnPropertyChanged();
+ }
+ }
+
+ protected override void InsertItem (int index, GroupAction item)
+ {
+ item.Parent = this;
+ base.InsertItem (index, item);
+ }
+
+ void OnPropertyChanged ([CallerMemberName] string propertyName = null)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ handler (this, new PropertyChangedEventArgs (propertyName));
+ }
+ }
+
+ class GroupAction
+ {
+ readonly Action<GroupAction> _action;
+
+ public GroupAction (string name, Action<GroupAction> action = null)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+
+ Name = name;
+ _action = action;
+ }
+
+ public string Name
+ {
+ get;
+ private set;
+ }
+
+ public void DoStuff()
+ {
+ if (_action == null)
+ return;
+
+ _action (this);
+ }
+
+ public Group Parent
+ {
+ get;
+ set;
+ }
+ }
+
+ readonly ListView _list = new ListView {
+ IsGroupingEnabled = true,
+ GroupHeaderTemplate = new DataTemplate(() => {
+ var label = new Label {
+ VerticalOptions = LayoutOptions.CenterAndExpand,
+ TextColor = Color.Red
+ };
+
+ label.SetBinding (Label.TextProperty, "Name");
+
+ return new ViewCell {
+ View = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ new Image {
+ Source = ImageSource.FromFile ("cover1.jpg"),
+ HeightRequest = 20,
+ WidthRequest = 20
+ },
+
+ label,
+ }
+ }
+ };
+ }),
+
+ ItemTemplate = new DataTemplate (() => {
+ var c = new TextCell();
+ c.SetBinding (TextCell.TextProperty, "Name");
+ return c;
+ })
+ };
+
+ readonly ObservableList<Group> _groups;
+
+ ObservableList<Group> CreateItemSource()
+ {
+ return new ObservableList<Group> {
+ new Group ("General") {
+ new GroupAction ("Change group name", ga => ga.Parent.Name += " (changed)"),
+ new GroupAction ("Change group short name", ga => ga.Parent.ShortName = ga.Parent.Name[1].ToString())
+ },
+
+ new Group ("Child item actions") {
+ new GroupAction ("Clear this group", ga => ga.Parent.Clear()),
+ new GroupAction ("Insert group item", ga => ga.Parent.Insert (1, new GroupAction ("Inserted item S"))),
+ new GroupAction ("Insert 2 group items", ga => ga.Parent.InsertRange (1, GetGroupActions ("Inserted item D", 2))),
+ new GroupAction ("Remove next item", ga => ga.Parent.Remove (ga.Parent[GetIndexOfDummy (ga)])),
+ new GroupAction ("Dummy item RDI"),
+ new GroupAction ("Remove next 2 dummy items", ga => ga.Parent.RemoveRange (GetNextDummyItems (ga, 2))),
+ new GroupAction ("Dummy item RmDI-1"),
+ new GroupAction ("Dummy item RmDI-2"),
+ new GroupAction ("Replace dummy item", ga => ga.Parent[GetIndexOfDummy(ga)] = new GroupAction ("Replaced item")),
+ new GroupAction ("Dummy item RpDI"),
+ new GroupAction ("Replace next two dummy items", ga =>
+ ga.Parent.ReplaceRange (GetIndexOfDummy (ga, 2), GetGroupActions ("Replaced items", 2))),
+ new GroupAction ("Dummy item RpDI-1"),
+ new GroupAction ("Dummy item RpDI-2"),
+ new GroupAction ("Select next dummy item", ga => {
+ int index = GetIndexOfDummy (ga);
+ _list.SelectedItem = ga.Parent[index];
+ }),
+ new GroupAction ("Dummy item SI"),
+ new GroupAction ("Move dummy above this one", ga => {
+ int nindex = GetIndexOfDummy (ga);
+ ga.Parent.Move (nindex, ga.Parent.IndexOf (c => c.Name.StartsWith ("Move dummy")));
+ }),
+ new GroupAction ("Dummy item MDI"),
+ new GroupAction ("Move last 2 items above this one", ga => {
+ int nindex = GetIndexOfDummy (ga, 2);
+ ga.Parent.Move (nindex, ga.Parent.IndexOf (c => c.Name.StartsWith ("Move last 2")), 2);
+ }),
+ new GroupAction ("Dummy item M2DI-1"),
+ new GroupAction ("Dummy item M2DI-2"),
+ },
+
+ CreateDummyGroup (2),
+ CreateDummyGroup (2),
+
+ new Group ("Group item actions") {
+ new GroupAction ("Clear all", ga => _groups.Clear()),
+ new GroupAction ("Insert group", ga => {
+ int index = _groups.IndexOf (g => g.Name == "Group item actions");
+ _groups.Insert (index, CreateDummyGroup (2));
+ }),
+
+ new GroupAction ("Insert 2 groups", ga => {
+ int index = _groups.IndexOf (g => g.Name == "Group item actions");
+ _groups.InsertRange (index, new[] { CreateDummyGroup (2), CreateDummyGroup (2) });
+ }),
+
+ new GroupAction ("Remove previous dummy group", ga => {
+ int index = _groups.IndexOf (g => g.Name == "Group item actions");
+ var dg = _groups.Take (index).Last (g => g.Name == "Dummy group");
+ _groups.Remove (dg);
+ }),
+
+ new GroupAction ("Remove previous 2 dummy groups", ga => {
+ int index = _groups.IndexOf (g => g.Name == "Group item actions");
+ var dgs = _groups.Take (index).Reverse().Where (g => g.Name == "Dummy group").Take (2);
+ _groups.RemoveRange (dgs);
+ }),
+
+ new GroupAction ("Replace previous dummy group", ga => {
+ int index = _groups.IndexOf (g => g.Name == "Group item actions");
+ var dg = _groups.Take (index).Last (g => g.Name == "Dummy group");
+ _groups[_groups.IndexOf (dg)] = new Group ("Replaced group") {
+ new GroupAction ("Replaced group item")
+ };
+ }),
+
+ new GroupAction ("Replace previous 2 dummy groups", ga => {
+ int index = _groups.IndexOf (g => g.Name == "Group item actions");
+ var dgs = _groups.Take (index).Reverse().Where (g => g.Name == "Dummy group").Take (2).Reverse();
+ _groups.ReplaceRange (_groups.IndexOf (dgs.First()), new[] {
+ new Group ("Replaced group") {
+ new GroupAction ("Replaced group item")
+ },
+ new Group ("Replaced group") {
+ new GroupAction ("Replaced group item")
+ }
+ });
+ }),
+
+ new GroupAction ("Move next group above", ga => {
+ int index = _groups.IndexOf (g => g.Name == ga.Parent.Name);
+ int dgindex = _groups.IndexOf (_groups.Skip (index + 1).First (dg => dg.Name == "Dummy group"));
+ _groups.Move (dgindex, index);
+ }),
+
+ new GroupAction ("Move next 2 groups above", ga => {
+ int index = _groups.IndexOf (g => g.Name == ga.Parent.Name);
+ int dgindex = _groups.IndexOf (_groups.Skip (index + 1).First (dg => dg.Name == "Dummy group"));
+ _groups.Move (dgindex, index, 2);
+ }),
+ },
+
+ CreateDummyGroup (1),
+ CreateDummyGroup (1),
+ CreateDummyGroup (1)
+ };
+ }
+
+ public GroupedListActionsGallery()
+ {
+ NavigationPage.SetHasNavigationBar (this, false);
+ _groups = CreateItemSource();
+
+ _list.ItemTapped += (sender, arg) => ((GroupAction)arg.Item).DoStuff();
+
+ _list.ItemsSource = _groups;
+ Title = "Actions";
+ Content = _list;
+ }
+
+ IEnumerable<GroupAction> GetGroupActions (string name, int count)
+ {
+ return Enumerable.Range (0, count).Select (i => new GroupAction (name + " " + i));
+ }
+
+ Group CreateDummyGroup (int children)
+ {
+ var group = new Group ("Dummy group");
+ group.AddRange (Enumerable.Range (0, children).Select (i => new GroupAction ("Dummy item")));
+ return group;
+ }
+
+ int GetIndexOfDummy (GroupAction source, int count = 1)
+ {
+ var dummies = GetNextDummyItems (source, count);
+ return source.Parent.IndexOf (dummies.First());
+ }
+
+ IEnumerable<GroupAction> GetNextDummyItems (GroupAction source, int count)
+ {
+ int start = source.Parent.IndexOf (source);
+ return source.Parent.Skip (start).Where (xga => xga.Name.StartsWith ("Dummy item")).Take (count);
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/GroupedListContactsGallery.cs b/Xamarin.Forms.Controls/GalleryPages/GroupedListContactsGallery.cs
new file mode 100644
index 00000000..1058b692
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/GroupedListContactsGallery.cs
@@ -0,0 +1,244 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ public class GroupedListContactsGallery
+ : ContentPage
+ {
+ internal class Contact
+ {
+ public string FirstName
+ {
+ get;
+ set;
+ }
+
+ public string LastName
+ {
+ get;
+ set;
+ }
+
+ public string FullName
+ {
+ get { return FirstName + " " + LastName; }
+ }
+
+ public string Title
+ {
+ get;
+ set;
+ }
+ }
+
+ readonly ListView _list = new ListView {
+ ItemTemplate = new DataTemplate (() => {
+ Label name = new Label();
+ name.SetBinding (Label.TextProperty, "FullName");
+
+ Label title = new Label { Font = Font.SystemFontOfSize (NamedSize.Micro) };
+ title.SetBinding (Label.TextProperty, "Title");
+
+ return new ViewCell { View = new StackLayout {
+ Children = {
+ name,
+ title
+ }
+ } };
+ }),
+
+ GroupDisplayBinding = new Binding ("Key"),
+ GroupShortNameBinding = new Binding ("Key"),
+ IsGroupingEnabled = true
+ };
+
+ readonly List<Contact> _contacts = new List<Contact> {
+ new Contact { FirstName = "Jason", LastName = "Smith", Title = "Software Engineer" },
+ new Contact { FirstName = "Eric", LastName = "Maupin", Title = "Software Engineer" },
+ new Contact { FirstName = "Seth", LastName = "Rosetter", Title = "Software Engineer" },
+ new Contact { FirstName = "Stephane", LastName = "Delcroix", Title = "Software Engineer" }
+ };
+
+ readonly Random _rand = new Random (42);
+
+ [Preserve (AllMembers = true)]
+ internal class Group
+ : ObservableCollection<Contact>
+ {
+ public Group (string key)
+ {
+ Key = key;
+ }
+
+ public string Key
+ {
+ get;
+ private set;
+ }
+ }
+
+ bool _sortedByFirst = true;
+ ObservableCollection<Group> _sortedContacts;
+
+ public GroupedListContactsGallery()
+ {
+ var addRandom = new Button { Text = "Random" };
+ addRandom.Clicked += (sender, args) => {
+ Contact contact = GetRandomContact();
+ _contacts.Add (contact);
+
+ AddContact (_sortedContacts, contact);
+ };
+
+ var addRandomToExisting = new Button { Text = "Random Group" };
+ addRandomToExisting.Clicked += (sender, args) => {
+ Contact contact;
+ do {
+ contact = GetRandomContact();
+ } while (!_sortedContacts.Any (g => GetSortChar (g.First()) == GetSortChar (contact)));
+
+ _contacts.Add (contact);
+ AddContact (_sortedContacts, contact);
+ };
+
+ var groupByFirst = new Button { Text = "First" };
+ groupByFirst.Clicked += (sender, args) => {
+ _sortedByFirst = true;
+
+ SetupContacts();
+ _list.ItemsSource = _sortedContacts;
+ };
+
+ var groupByLast = new Button { Text = "Last" };
+ groupByLast.Clicked += (sender, args) => {
+ _sortedByFirst = false;
+
+ SetupContacts();
+ _list.ItemsSource = _sortedContacts;
+ };
+
+ Content = new StackLayout {
+ Orientation = StackOrientation.Vertical,
+ Children = {
+ new StackLayout {
+ Orientation = StackOrientation.Vertical,
+ Children = {
+ new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ new Label { Text = "Sort: " },
+ groupByFirst,
+ groupByLast
+ }
+ },
+
+ new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ addRandom,
+ addRandomToExisting,
+ }
+ }
+ },
+ },
+
+
+ _list
+ }
+ };
+
+ SetupContacts();
+ _list.ItemsSource = _sortedContacts;
+ }
+
+ const string Chars = "abcdefghijklmnopqrstuvwxyz";
+
+ void SetupContacts()
+ {
+ var coll = new ObservableCollection<Group>();
+ foreach (var contact in _contacts)
+ AddContact (coll, contact);
+
+ _sortedContacts = coll;
+ }
+
+ void AddContact (ObservableCollection<Group> contactGroups, Contact contact)
+ {
+ char sortChar = GetSortChar (contact);
+
+ var collection = contactGroups.FirstOrDefault (col => {
+ var c = col.First();
+ return (GetSortChar (c) == sortChar);
+ });
+
+ if (collection == null) {
+ var ocontacts = new Group (GetSortChar (contact).ToString()) { contact };
+ InsertBasedOnSort (contactGroups, ocontacts, c => GetSortChar (c.First()));
+ } else
+ InsertBasedOnSort (collection, contact, c => GetSortString (c)[0]);
+ }
+
+ int IndexOf<T> (IEnumerable<T> elements, T element)
+ {
+ int i = 0;
+ foreach (T e in elements) {
+ if (Equals (e, element))
+ return i;
+
+ i++;
+ }
+
+ return -1;
+ }
+
+ void InsertBasedOnSort<T,TSort> (IList<T> items, T item, Func<T, TSort> sortBy)
+ {
+ List<T> newItems = new List<T> (items);
+ newItems.Add (item);
+ int index = IndexOf (newItems.OrderBy (sortBy), item);
+ items.Insert (index, item);
+ }
+
+ char GetSortChar (Contact contact)
+ {
+ return GetSortString (contact)[0];
+ }
+
+ string GetSortString (Contact contact)
+ {
+ return (_sortedByFirst) ? contact.FirstName : contact.LastName;
+ }
+
+ Contact GetRandomContact()
+ {
+ Contact contact = new Contact();
+
+ int firstLen = _rand.Next (3, 7);
+
+ var builder = new StringBuilder (firstLen);
+ for (int i = 0; i < firstLen; i++) {
+ char c = Chars[_rand.Next (0, Chars.Length)];
+ builder.Append ((i != 0) ? c : char.ToUpper (c));
+ }
+
+ contact.FirstName = builder.ToString();
+
+ int lastLen = _rand.Next (3, 7);
+ builder.Clear();
+ for (int i = 0; i < lastLen; i++) {
+ char c = Chars[_rand.Next (0, Chars.Length)];
+ builder.Append ((i != 0) ? c : char.ToUpper (c));
+ }
+
+ contact.LastName = builder.ToString();
+ contact.Title = "Software Engineer";
+
+ return contact;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ImageGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ImageGallery.cs
new file mode 100644
index 00000000..9d4a32c9
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ImageGallery.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ImageGallery : ContentPage
+ {
+ public ImageGallery ()
+ {
+
+ Padding = new Thickness (20);
+
+ var normal = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
+ var disabled = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
+ var rotate = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
+ var transparent = new Image { Source = ImageSource.FromFile ("cover1.jpg") };
+ var embedded = new Image { Source = ImageSource.FromResource ("Xamarin.Forms.Controls.ControlGalleryPages.crimson.jpg", typeof (ImageGallery)) };
+
+ // let the stack shrink the images
+ normal.MinimumHeightRequest = normal.MinimumHeightRequest = 10;
+ disabled.MinimumHeightRequest = disabled.MinimumHeightRequest = 10;
+ rotate.MinimumHeightRequest = rotate.MinimumHeightRequest = 10;
+ transparent.MinimumHeightRequest = transparent.MinimumHeightRequest = 10;
+ embedded.MinimumHeightRequest = 10;
+
+ disabled.IsEnabled = false;
+ rotate.GestureRecognizers.Add (new TapGestureRecognizer { Command = new Command (o => rotate.RelRotateTo (180))});
+ transparent.Opacity = .5;
+
+ Content = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ new StackLayout {
+ //MinimumWidthRequest = 20,
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ Children = {
+ normal,
+ disabled,
+ transparent,
+ rotate,
+ embedded,
+ new StackLayout {
+ HeightRequest = 30,
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ new Image {Source = "cover1.jpg"},
+ new Image {Source = "cover1.jpg"},
+ new Image {Source = "cover1.jpg"},
+ new Image {Source = "cover1.jpg"}
+ }
+ }
+ }
+ },
+ new StackLayout {
+ WidthRequest = 30,
+ Children = {
+ new Image {Source = "cover1.jpg"},
+ new Image {Source = "cover1.jpg"},
+ new Image {Source = "cover1.jpg"},
+ new Image {Source = "cover1.jpg"}
+ }
+ }
+
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ImageLoadingGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ImageLoadingGallery.cs
new file mode 100644
index 00000000..f916d7dc
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ImageLoadingGallery.cs
@@ -0,0 +1,43 @@
+using System;
+using System.ComponentModel;
+
+namespace Xamarin.Forms.Controls
+{
+
+ public class ImageLoadingGallery : ContentPage
+ {
+ public ImageLoadingGallery ()
+ {
+ Padding = new Thickness (20);
+
+ var source = new UriImageSource {
+ Uri = new Uri ("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg"),
+ CachingEnabled = false
+ };
+
+ var image = new Image {
+ Source = source,
+ WidthRequest = 200,
+ HeightRequest = 200,
+ };
+
+ var indicator = new ActivityIndicator {Color = new Color (.5),};
+ indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading");
+ indicator.BindingContext = image;
+
+ var grid = new Grid();
+ grid.RowDefinitions.Add (new RowDefinition());
+ grid.RowDefinitions.Add (new RowDefinition());
+
+ grid.Children.Add (image);
+ grid.Children.Add (indicator);
+
+ var cancel = new Button { Text = "Cancel" };
+ cancel.Clicked += (s, e) => source.Cancel();
+ Grid.SetRow (cancel, 1);
+ grid.Children.Add (cancel);
+
+ Content = grid;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/InputIntentGallery.cs b/Xamarin.Forms.Controls/GalleryPages/InputIntentGallery.cs
new file mode 100644
index 00000000..0f1461bf
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/InputIntentGallery.cs
@@ -0,0 +1,101 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class InputIntentGallery : ContentPage
+ {
+ public InputIntentGallery ()
+ {
+ var label = new Label {
+ Text = "Custom Not Focused"
+ };
+
+ var label2 = new Label {
+ Text = ""
+ };
+
+ var defaultEntry = new Entry {
+ Placeholder = "Default",
+ Keyboard = Keyboard.Default
+ };
+
+ defaultEntry.Completed += (sender, e) => label2.Text = "Default completed";
+
+ var emailEntry = new Entry {
+ Placeholder = "Email Input",
+ Keyboard = Keyboard.Email
+ };
+
+ emailEntry.Completed += (sender, e) => label2.Text = "Email completed";
+
+ var textEntry = new Entry {
+ Placeholder = "Text Input",
+ Keyboard = Keyboard.Text
+ };
+
+ textEntry.Completed += (sender, e) => label2.Text = "Text completed";
+
+ var urlEntry = new Entry {
+ Placeholder = "Url Input",
+ Keyboard = Keyboard.Url
+ };
+
+ urlEntry.Completed += (sender, e) => label2.Text = "URL completed";
+
+ var numericEntry = new Entry {
+ Placeholder = "Numeric Input",
+ Keyboard = Keyboard.Numeric
+ };
+
+ numericEntry.Completed += (sender, e) => label2.Text = "Numeric completed";
+
+ var telephoneEntry = new Entry {
+ Placeholder = "Telephone Input",
+ Keyboard = Keyboard.Telephone
+ };
+
+ telephoneEntry.Completed += (sender, e) => label2.Text = "Telephone completed";
+
+ var chatEntry = new Entry {
+ Placeholder = "Chat Input",
+ Keyboard = Keyboard.Chat
+ };
+
+ chatEntry.Completed += (sender, e) => label2.Text = "Chat completed";
+
+ var customEntry = new Entry {
+ Placeholder = "Custom Entry",
+ Keyboard = Keyboard.Create (KeyboardFlags.CapitalizeSentence)
+ };
+
+ customEntry.Completed += (sender, e) => label2.Text = "Custom completed";
+
+ customEntry.Focused += (s, e) => {
+ label.Text = "Custom Focused";
+ };
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ VerticalOptions = LayoutOptions.Center,
+ Padding = new Thickness (40, 20),
+ Children = {
+ label,
+ label2,
+ defaultEntry,
+ emailEntry,
+ textEntry,
+ urlEntry,
+ numericEntry,
+ telephoneEntry,
+ chatEntry,
+ customEntry
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs b/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs
new file mode 100644
index 00000000..65210969
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class LabelGallery : ContentPage
+ {
+ public LabelGallery ()
+ {
+ var normal = new Label { Text = "Normal Label" };
+ var center = new Label { Text = "Center Label" };
+ var right = new Label { Text = "Right Label" };
+ var moving = new Label { Text = "Move On Click" };
+ var click = new Label { Text = "Click Label" };
+ var rotate = new Label { Text = "Rotate Label" };
+ var transparent = new Label { Text = "Transparent Label" };
+ var color = new Label { Text = "Color Change" };
+ var micro = new Label { Text = "Micro Label" };
+ var small = new Label { Text = "Small Label" };
+ var medium = new Label { Text = "Medium Label" };
+ var large = new Label { Text = "Large Label", VerticalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center};
+ var bold = new Label { Text = "Bold Label" };
+ var italic = new Label { Text = "Italic Label" };
+ var bolditalic = new Label { Text = "Bold Italic Label" };
+ var customFont = new Label { Text = "Custom Font" };
+ var italicfont = new Label { Text = "Custom Italic Font" };
+ var boldfont = new Label { Text = "Custom Bold Font" };
+ var bolditalicfont = new Label { Text = "Custom Bold Italic Font" };
+ var huge = new Label {
+ Text = "This is the label that never ends, yes it go on and on my friend. " +
+ "Some people started catting it not knowing what it was, and they'll continue catting it forever just because...",
+ LineBreakMode = LineBreakMode.WordWrap
+ };
+ var formatted = new Label { FormattedText = new FormattedString {
+ Spans = {
+ new Span {Text="FormattedStrings ", ForegroundColor=Color.Blue, BackgroundColor = Color.Yellow, Font = Font.BoldSystemFontOfSize (NamedSize.Large)},
+ new Span {Text="are ", ForegroundColor=Color.Red, BackgroundColor = Color.Gray},
+ new Span {Text="not pretty!", ForegroundColor = Color.Green,},
+ }
+ } };
+ var missingfont = new Label { Text = "Missing font: use default" };
+
+ micro.Font = Font.SystemFontOfSize (NamedSize.Micro);
+ small.Font = Font.SystemFontOfSize (NamedSize.Small);
+ medium.Font = Font.SystemFontOfSize (NamedSize.Medium);
+ large.Font = Font.SystemFontOfSize (NamedSize.Large);
+
+ bold.Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold);
+ italic.Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Italic);
+ bolditalic.Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold | FontAttributes.Italic);
+
+ var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS");
+ var font = Font.OfSize (fontName, NamedSize.Medium);
+ customFont.Font = font;
+ italicfont.Font = font.WithAttributes (FontAttributes.Italic);
+ boldfont.Font = font.WithAttributes (FontAttributes.Bold);
+ bolditalicfont.Font = font.WithAttributes (FontAttributes.Bold | FontAttributes.Italic);
+
+ customFont.GestureRecognizers.Add (new TapGestureRecognizer{Command = new Command (o => customFont.Font = Font.Default)});
+
+ missingfont.Font = Font.OfSize ("FooBar", 20);
+ center.HorizontalTextAlignment = TextAlignment.Center;
+ right.HorizontalTextAlignment = TextAlignment.End;
+ int i = 1;
+ click.GestureRecognizers.Add (new TapGestureRecognizer{Command = new Command (o=>click.Text = "Clicked " + i++)});
+ rotate.GestureRecognizers.Add (new TapGestureRecognizer{Command = new Command (o=>rotate.RelRotateTo (180))});
+ transparent.Opacity = .5;
+ moving.GestureRecognizers.Add (new TapGestureRecognizer{Command = new Command (o=>moving.HorizontalTextAlignment = TextAlignment.End)});
+
+ color.GestureRecognizers.Add (new TapGestureRecognizer{Command = new Command (o=>{
+ color.TextColor = new Color (1, 0, 0);
+ color.BackgroundColor = new Color (0, 1, 0);
+ })});
+
+ Thickness padding = new Thickness (20);
+ // Padding Adjust for iPad
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet)
+ padding = new Thickness (20, 20, 20, 60);
+ });
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Padding = padding,
+ Children = {
+ formatted,
+ normal,
+ center,
+ right,
+ huge,
+ moving,
+ click,
+ rotate,
+ transparent,
+ color,
+ micro,
+ small,
+ medium,
+ large,
+ bold,
+ italic,
+ bolditalic,
+ customFont,
+ italicfont,
+ boldfont,
+ bolditalicfont,
+ missingfont,
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/LayoutOptionsGallery.cs b/Xamarin.Forms.Controls/GalleryPages/LayoutOptionsGallery.cs
new file mode 100644
index 00000000..13c6c575
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/LayoutOptionsGallery.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class LayoutOptionsGallery : ContentPage
+ {
+ public LayoutOptionsGallery ()
+ {
+ Build ();
+ }
+
+ void Build ()
+ {
+ var mainLayout = new StackLayout {
+ BackgroundColor = Color.Silver,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ Children = {
+ BuildLayoutRegion (),
+ BuildLayoutRegion ()
+ }
+ };
+
+ var changeOrientationButton = new Button {Text = "Change Orientation"};
+ changeOrientationButton.Clicked += (sender, args) => mainLayout.Orientation = (mainLayout.Orientation == StackOrientation.Horizontal) ? StackOrientation.Vertical : StackOrientation.Horizontal;
+
+ Content = new StackLayout {
+ Children = {
+ changeOrientationButton,
+ mainLayout
+ }
+ };
+ }
+
+ LayoutOptions StringToLayoutOptions (string options)
+ {
+ switch (options) {
+ case "Start":
+ return LayoutOptions.Start;
+ case "StartAndExpand":
+ return LayoutOptions.StartAndExpand;
+ case "Center":
+ return LayoutOptions.Center;
+ case "CenterAndExpand":
+ return LayoutOptions.CenterAndExpand;
+ case "End":
+ return LayoutOptions.End;
+ case "EndAndExpand":
+ return LayoutOptions.EndAndExpand;
+ case "Fill":
+ return LayoutOptions.Fill;
+ case "FillAndExpand":
+ return LayoutOptions.FillAndExpand;
+ }
+ throw new InvalidDataException ();
+ }
+
+ View BuildLayoutRegion ()
+ {
+ // Set these to fill and expand so they just fill their parent which is the thing we actually want to play with.
+ var horizontalButton = new Button {
+ Text = "H Options",
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ };
+
+ var verticalButton = new Button {
+ Text = "V Options",
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ };
+
+ var result = new StackLayout {
+ BackgroundColor = Color.Gray,
+ Children = {
+ horizontalButton,
+ verticalButton
+ }
+ };
+
+ horizontalButton.Clicked += async (sender, args) => {
+ var selection = await DisplayActionSheet ("Select Horizontal Options", null, null,
+ "Start", "StartAndExpand",
+ "Center", "CenterAndExpand",
+ "End", "EndAndExpand",
+ "Fill", "FillAndExpand");
+
+ result.HorizontalOptions = StringToLayoutOptions (selection);
+ };
+
+ verticalButton.Clicked += async (sender, args) => {
+ var selection = await DisplayActionSheet ("Select Horizontal Options", null, null,
+ "Start", "StartAndExpand",
+ "Center", "CenterAndExpand",
+ "End", "EndAndExpand",
+ "Fill", "FillAndExpand");
+
+ result.VerticalOptions = StringToLayoutOptions (selection);
+ };
+
+ return result;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/LayoutPerformanceGallery.cs b/Xamarin.Forms.Controls/GalleryPages/LayoutPerformanceGallery.cs
new file mode 100644
index 00000000..9778e372
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/LayoutPerformanceGallery.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls.GalleryPages
+{
+ public class LayoutPerformanceGallery : ContentPage
+ {
+ public LayoutPerformanceGallery ()
+ {
+ int size = 3;
+
+ var grid = new Grid {
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ RowDefinitions = {
+ new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) },
+ new RowDefinition { Height = new GridLength (5, GridUnitType.Star) },
+ new RowDefinition { Height = new GridLength (7, GridUnitType.Star) },
+ },
+ ColumnDefinitions = {
+ new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (100, GridUnitType.Absolute) },
+ new ColumnDefinition { Width = new GridLength (7, GridUnitType.Star) },
+ }
+ };
+
+ for (int i = 0; i < size; i++) {
+ for (int j = 0; j < size; j++) {
+ var g = new Grid {
+ RowDefinitions = {
+ new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) },
+ new RowDefinition { Height = new GridLength (5, GridUnitType.Star) },
+ new RowDefinition { Height = new GridLength (7, GridUnitType.Star) },
+ },
+ ColumnDefinitions = {
+ new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
+ new ColumnDefinition { Width = new GridLength (100, GridUnitType.Absolute) },
+ new ColumnDefinition { Width = new GridLength (7, GridUnitType.Star) },
+ }
+ };
+
+ for (int k = 0; k < size; k++) {
+ for (int l = 0; l < size; l++) {
+ var label = new Label { Text = "10" };
+ g.Children.Add (label, k, l);
+ _labelList.Add (label);
+ }
+ }
+
+ grid.Children.Add (g, i, j);
+ }
+ }
+
+
+
+
+ Content = new StackLayout {
+ Children = {
+ (_mainLabel = new Label ()),
+ grid
+ }
+ };
+ }
+
+ Label _mainLabel = null;
+ List<Label> _labelList = new List<Label> ();
+ Stopwatch _sw = new Stopwatch ();
+ long _ticks = 0;
+ int _count = 0;
+ int _cycle = 0;
+ bool _flip = true;
+ Random _r = new Random (34269027);
+ bool _repeat = false;
+
+ protected override void OnAppearing ()
+ {
+ base.OnAppearing ();
+ _repeat = true;
+ Device.StartTimer (TimeSpan.FromMilliseconds (10), () => {
+ _sw.Start ();
+ foreach (var label in _labelList) {
+ if (_flip) {
+ label.Text = _r.Next (10, 40).ToString ();
+ } else {
+ label.Text = _r.Next (50, 90).ToString ();
+ }
+ }
+ _sw.Stop ();
+ _ticks += _sw.ElapsedMilliseconds;
+ _sw.Reset ();
+
+ _cycle = (_cycle + 1) % 100;
+ _count++;
+ if (_cycle == 0) {
+ _mainLabel.Text = string.Format ("Avg Time: {0:0.000}ms", _ticks / (double)_count);
+ }
+
+ _flip = !_flip;
+ return _repeat;
+ });
+ }
+
+ protected override void OnDisappearing ()
+ {
+ _repeat = false;
+ _ticks = 0;
+ _count = 0;
+ _cycle = 0;
+
+ base.OnDisappearing ();
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/LineBreakModeGallery.cs b/Xamarin.Forms.Controls/GalleryPages/LineBreakModeGallery.cs
new file mode 100644
index 00000000..8089bc79
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/LineBreakModeGallery.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class LineBreakModeGallery : ContentPage
+ {
+ public LineBreakModeGallery ()
+ {
+ var label = new Label {
+ Text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
+ };
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Spacing = 0,
+ Children = {
+ MakeLineBreakModeButton ("CharacterWrap", label, LineBreakMode.CharacterWrap),
+ MakeLineBreakModeButton ("HeadTruncation", label, LineBreakMode.HeadTruncation),
+ MakeLineBreakModeButton ("MiddleTruncation", label, LineBreakMode.MiddleTruncation),
+ MakeLineBreakModeButton ("NoWrap", label, LineBreakMode.NoWrap),
+ MakeLineBreakModeButton ("TailTruncation", label, LineBreakMode.TailTruncation),
+ MakeLineBreakModeButton ("WordWrap", label, LineBreakMode.WordWrap),
+ label
+ }
+ }
+ };
+ }
+
+ static Button MakeLineBreakModeButton (string buttonText, Label label, LineBreakMode lineBreakMode) {
+ var button = new Button {
+ Text = buttonText,
+ Command = new Command (() => label.LineBreakMode = lineBreakMode)
+ };
+ return button;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ListPage.cs b/Xamarin.Forms.Controls/GalleryPages/ListPage.cs
new file mode 100644
index 00000000..0eeaf147
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ListPage.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ListPage : ContentPage
+ {
+ ListScreen _listScreen;
+ public ListPage ()
+ {
+ _listScreen = new ListScreen ();
+ Content = new StackLayout {
+ Children = {
+ new Label {Text = "Foo"},
+ _listScreen.View
+ }
+ };
+ }
+ }
+
+ public class ListScreen
+ {
+ public ListView View { get; private set; }
+
+ internal class A : INotifyPropertyChanged
+ {
+ string _text;
+ public string Text {
+ get {
+ return _text;
+ }
+ set {
+ _text = value;
+ if(PropertyChanged != null)
+ PropertyChanged(this, new PropertyChangedEventArgs("Text"));
+ }
+ }
+
+ #region INotifyPropertyChanged implementation
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ #endregion
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class ViewCellTest : ViewCell
+ {
+ static int s_inc = 0;
+
+ public ViewCellTest ()
+ {
+ var stackLayout = new StackLayout {
+ Orientation = StackOrientation.Horizontal
+ };
+
+ var label = new Label ();
+ label.SetBinding (Label.TextProperty, "Text");
+
+ var box = new BoxView {WidthRequest = 100, HeightRequest = 10, Color = Color.Red};
+
+ stackLayout.Children.Add (label);
+ stackLayout.Children.Add (box);
+
+ View = stackLayout;
+ }
+
+ protected override void OnAppearing ()
+ {
+ base.OnAppearing ();
+ Debug.WriteLine ("Appearing: " + (BindingContext as A)?.Text + " : " + s_inc);
+ s_inc++;
+ }
+
+ protected override void OnDisappearing ()
+ {
+ base.OnDisappearing ();
+ Debug.WriteLine ("Disappearing: " + (BindingContext as A)?.Text + " : " + s_inc);
+ s_inc++;
+ }
+ }
+
+ public ListScreen ()
+ {
+
+ View = new ListView (ListViewCachingStrategy.RecycleElement);
+
+ View.RowHeight = 30;
+
+ var n = 500;
+ var items = Enumerable.Range (0, n).Select (i => new A {Text = i.ToString ()}).ToList ();
+ View.ItemsSource = items;
+
+ View.ItemTemplate = new DataTemplate (typeof (ViewCellTest));
+
+ View.ItemSelected += (sender, e) => {
+ var cell = (e.SelectedItem as A);
+ if (cell == null)
+ return;
+ var x = int.Parse (cell.Text);
+ if (x == 5) {
+ n += 10;
+ View.ItemsSource = Enumerable.Range (0, n).Select (i => new A { Text = i.ToString () }).ToList ();
+ } else {
+ cell.Text = (x + 1).ToString ();
+ }
+ };
+
+
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs b/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs
new file mode 100644
index 00000000..a30ec170
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs
@@ -0,0 +1,231 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class ListViewDemoPage : ContentPage
+ {
+ class Person
+ {
+ public Person(string name, DateTime birthday, Color favoriteColor)
+ {
+ Name = name;
+ Birthday = birthday;
+ FavoriteColor = favoriteColor;
+ }
+
+ public string Name { private set; get; }
+
+ public DateTime Birthday { private set; get; }
+
+ public Color FavoriteColor { private set; get; }
+ };
+
+ class MyDataTemplateSelector : DataTemplateSelector
+ {
+ DataTemplate _oddTemplate;
+ DataTemplate _evenTemplate;
+
+ public MyDataTemplateSelector ()
+ {
+ _evenTemplate = new DataTemplate (() => {
+ // Create views with bindings for displaying each property.
+ Label nameLabel = new Label ();
+ nameLabel.SetBinding (Label.TextProperty, "Name");
+
+ Label birthdayLabel = new Label ();
+ birthdayLabel.SetBinding (Label.TextProperty,
+ new Binding ("Birthday", BindingMode.OneWay,
+ null, null, "Born {0:d}"));
+
+ BoxView boxView = new BoxView ();
+ boxView.SetBinding (BoxView.ColorProperty, "FavoriteColor");
+
+ // Return an assembled ViewCell.
+ return new ViewCell {
+ View = new StackLayout {
+ Padding = new Thickness (0, 5),
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ new Image {
+ HeightRequest = 40,
+ WidthRequest = 40,
+ Source = new UriImageSource {
+ // CacheValidity = TimeSpan.FromSeconds (10),
+ Uri = new Uri ("https://xamarin.com/content/images/pages/index/xamarin-studio-icon.png"),
+ }
+ },
+ boxView,
+ new StackLayout {
+ VerticalOptions = LayoutOptions.Center,
+ Spacing = 0,
+ Children = {
+ nameLabel,
+ birthdayLabel
+ }
+ }
+ }
+ }
+ };
+ });
+
+ _oddTemplate = new DataTemplate (() => {
+ // Create views with bindings for displaying each property.
+ Label nameLabel = new Label ();
+ nameLabel.SetBinding (Label.TextProperty, "Name");
+
+ Label birthdayLabel = new Label ();
+ birthdayLabel.SetBinding (Label.TextProperty,
+ new Binding ("Birthday", BindingMode.OneWay,
+ null, null, "Born {0:d}"));
+
+ BoxView boxView = new BoxView ();
+ boxView.SetBinding (BoxView.ColorProperty, "FavoriteColor");
+
+ // Return an assembled ViewCell.
+ return new ViewCell {
+ View = new StackLayout {
+ Padding = new Thickness (0, 5),
+ Orientation = StackOrientation.Horizontal,
+ Children = {
+ new Image {
+ HeightRequest = 40,
+ WidthRequest = 40,
+ Source = new UriImageSource {
+ // CacheValidity = TimeSpan.FromSeconds (10),
+ Uri = new Uri ("https://xamarin.com/content/images/pages/index/xamarin-studio-icon.png"),
+ }
+ },
+
+ new StackLayout {
+ VerticalOptions = LayoutOptions.Center,
+ Spacing = 0,
+ Children = {
+ birthdayLabel,
+ nameLabel,
+ }
+ },
+ boxView,
+ }
+ }
+ };
+ });
+ }
+
+ protected override DataTemplate OnSelectTemplate (object item, BindableObject container)
+ {
+ return ((Person)item).Birthday.Month % 2 == 0 ? _evenTemplate : _oddTemplate;
+ }
+ }
+
+ public ListViewDemoPage()
+ {
+ Label header = new Label
+ {
+ Text = "ListView",
+ Font = Font.BoldSystemFontOfSize(50),
+ HorizontalOptions = LayoutOptions.Center
+ };
+
+ // Define some data.
+ List<Person> people = new List<Person>
+ {
+ new Person("Abigail", new DateTime(1975, 1, 15), Color.Aqua),
+ new Person("Bob", new DateTime(1976, 2, 20), Color.Black),
+ new Person("Cathy", new DateTime(1977, 3, 10), Color.Blue),
+ new Person("David", new DateTime(1978, 4, 25), Color.Fuschia),
+ new Person("Eugenie", new DateTime(1979, 5, 5), Color.Gray),
+ new Person("Freddie", new DateTime(1980, 6, 30), Color.Green),
+ new Person("Greta", new DateTime(1981, 7, 15), Color.Lime),
+ new Person("Harold", new DateTime(1982, 8, 10), Color.Maroon),
+ new Person("Irene", new DateTime(1983, 9, 25), Color.Navy),
+ new Person("Jonathan", new DateTime(1984, 10, 10), Color.Olive),
+ new Person("Kathy", new DateTime(1985, 11, 20), Color.Purple),
+ new Person("Larry", new DateTime(1986, 12, 5), Color.Red),
+ new Person("Monica", new DateTime(1975, 1, 5), Color.Silver),
+ new Person("Nick", new DateTime(1976, 2, 10), Color.Teal),
+ new Person("Olive", new DateTime(1977, 3, 20), Color.White),
+ new Person("Pendleton", new DateTime(1978, 4, 10), Color.Yellow),
+ new Person("Queenie", new DateTime(1979, 5, 15), Color.Aqua),
+ new Person("Rob", new DateTime(1980, 6, 30), Color.Blue),
+ new Person("Sally", new DateTime(1981, 7, 5), Color.Fuschia),
+ new Person("Timothy", new DateTime(1982, 8, 30), Color.Green),
+ new Person("Uma", new DateTime(1983, 9, 10), Color.Lime),
+ new Person("Victor", new DateTime(1984, 10, 20), Color.Maroon),
+ new Person("Wendy", new DateTime(1985, 11, 5), Color.Navy),
+ new Person("Xavier", new DateTime(1986, 12, 30), Color.Olive),
+ new Person("Yvonne", new DateTime(1987, 1, 10), Color.Purple),
+ new Person("Zachary", new DateTime(1988, 2, 5), Color.Red)
+ };
+ List<Person> people2 = new List<Person>
+ {
+ new Person("Abigail", new DateTime(1975, 1, 15), Color.Aqua),
+ new Person("Bob", new DateTime(1976, 2, 20), Color.Black),
+ new Person("Cathy", new DateTime(1977, 3, 10), Color.Blue),
+ new Person("David", new DateTime(1978, 4, 25), Color.Fuschia),
+ new Person("Eugenie", new DateTime(1979, 5, 5), Color.Gray),
+ new Person("Freddie", new DateTime(1980, 6, 30), Color.Green),
+ new Person("Greta", new DateTime(1981, 7, 15), Color.Lime),
+ new Person("Harold", new DateTime(1982, 8, 10), Color.Maroon),
+ new Person("Irene", new DateTime(1983, 9, 25), Color.Navy),
+ new Person("Jonathan", new DateTime(1984, 10, 10), Color.Olive),
+ new Person("Kathy", new DateTime(1985, 11, 20), Color.Purple),
+ new Person("Larry", new DateTime(1986, 12, 5), Color.Red),
+ new Person("Monica", new DateTime(1975, 1, 5), Color.Silver),
+ new Person("Nick", new DateTime(1976, 2, 10), Color.Teal),
+ new Person("Olive", new DateTime(1977, 3, 20), Color.White),
+ new Person("Pendleton", new DateTime(1978, 4, 10), Color.Yellow),
+ new Person("Queenie", new DateTime(1979, 5, 15), Color.Aqua),
+ new Person("Rob", new DateTime(1980, 6, 30), Color.Blue),
+ new Person("Sally", new DateTime(1981, 7, 5), Color.Fuschia),
+ new Person("Timothy", new DateTime(1982, 8, 30), Color.Green),
+ new Person("Uma", new DateTime(1983, 9, 10), Color.Lime),
+ new Person("Victor", new DateTime(1984, 10, 20), Color.Maroon),
+ new Person("Wendy", new DateTime(1985, 11, 5), Color.Navy),
+ new Person("Xavier", new DateTime(1986, 12, 30), Color.Olive),
+ new Person("Yvonne", new DateTime(1987, 1, 10), Color.Purple),
+ new Person("Zachary", new DateTime(1988, 2, 5), Color.Red)
+ };
+
+ // Create the ListView.
+ ListView listView = new ListView (ListViewCachingStrategy.RecycleElement)
+ {
+ // Source of data items.
+ ItemsSource = new List<List<Person>> {people, people2},
+ IsPullToRefreshEnabled = true,
+ IsGroupingEnabled = true,
+
+ // Define template for displaying each item.
+ // (Argument of DataTemplate constructor is called for
+ // each item; it must return a Cell derivative.)
+ ItemTemplate = new MyDataTemplateSelector ()
+ };
+
+ listView.Refreshing += async (sender, e) => {
+ await Task.Delay (5000);
+ listView.IsRefreshing = false;
+ };
+
+ listView.ItemSelected += (sender, args) => {
+ if (listView.SelectedItem == null)
+ return;
+ listView.SelectedItem = null;
+ };
+
+ // Accomodate iPhone status bar.
+ Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
+
+ // Build the page.
+ Content = new StackLayout
+ {
+ Children =
+ {
+ header,
+ listView
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs b/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs
new file mode 100644
index 00000000..dd283c3a
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs
@@ -0,0 +1,153 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xamarin.Forms.Maps;
+
+namespace Xamarin.Forms.Controls
+{
+ public class MapGallery : ContentPage
+ {
+ readonly StackLayout _stack;
+
+ public MapGallery ()
+ {
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var map = MakeMap ();
+
+ map.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (41.890202, 12.492049), Distance.FromMiles (0.5)));
+
+ var searchAddress = new SearchBar { Placeholder = "Search Address" };
+
+ searchAddress.SearchButtonPressed += async (e, a) => {
+ var addressQuery = searchAddress.Text;
+ searchAddress.Text = "";
+ searchAddress.Unfocus ();
+
+ var positions = (await (new Geocoder ()).GetPositionsForAddressAsync (addressQuery)).ToList ();
+ if (!positions.Any ())
+ return;
+
+ var position = positions.First ();
+ map.MoveToRegion (MapSpan.FromCenterAndRadius (position,
+ Distance.FromMeters (4000)));
+ map.Pins.Add (new Pin {
+ Label = addressQuery,
+ Position = position,
+ Address = addressQuery
+ });
+ };
+
+ var buttonAddressFromPosition = new Button { Text = "Address From Position" };
+ buttonAddressFromPosition.Clicked += async (e, a) => {
+ var addresses = (await (new Geocoder ()).GetAddressesForPositionAsync (new Position (41.8902, 12.4923))).ToList ();
+ foreach (var ad in addresses)
+ Debug.WriteLine (ad);
+ };
+
+ var buttonZoomIn = new Button { Text = "Zoom In" };
+ buttonZoomIn.Clicked += (e, a) => map.MoveToRegion (map.VisibleRegion.WithZoom (5f));
+
+ var buttonZoomOut = new Button { Text = "Zoom Out" };
+ buttonZoomOut.Clicked += (e, a) => map.MoveToRegion (map.VisibleRegion.WithZoom (1 / 3f));
+
+ var mapTypeButton = new Button { Text = "Map Type" };
+ mapTypeButton.Clicked += async (e, a) => {
+ var result = await DisplayActionSheet ("Select Map Type", null, null, "Street", "Satellite", "Hybrid");
+ switch (result) {
+ case "Street":
+ map.MapType = MapType.Street;
+ break;
+ case "Satellite":
+ map.MapType = MapType.Satellite;
+ break;
+ case "Hybrid":
+ map.MapType = MapType.Hybrid;
+ break;
+ }
+ };
+
+ var buttonHome = new Button { Text = "Home" };
+ buttonHome.Clicked += (a, e) => {
+ map.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (41.890202, 12.492049), Distance.FromMiles (0.5)));
+ };
+
+ _stack = new StackLayout {
+ Spacing = 0,
+ Padding = new Thickness (30, 0)
+ };
+ //stack.SetRowSpacing (1, 0);
+
+ Title = "Map Gallery";
+
+ var buttonZoomPin = new Button { Text = "Zoom Pin" };
+ buttonZoomPin.Clicked += (a, e) => {
+ var pos = new Position (41.011995, -8.642995);
+ map.Pins.Clear ();
+ map.Pins.Add (new Pin { Position = pos, Label = "Rui" });
+ map.MoveToRegion (MapSpan.FromCenterAndRadius (pos, Distance.FromMiles (0.5)));
+ };
+
+
+ map.VerticalOptions = LayoutOptions.FillAndExpand;
+ _stack.Children.Add (searchAddress);
+ _stack.Children.Add (map);
+ _stack.Children.Add (mapTypeButton);
+ _stack.Children.Add (buttonZoomIn);
+ _stack.Children.Add (buttonZoomOut);
+ _stack.Children.Add (buttonAddressFromPosition);
+ _stack.Children.Add (buttonHome);
+ _stack.Children.Add (buttonZoomPin);
+
+ Content = _stack;
+ }
+
+ public static Map MakeMap ()
+ {
+ Pin colosseum = null;
+ Pin pantheon = null;
+ Pin chapel = null;
+
+ var map = new Map {
+ IsShowingUser = false,
+ Pins = {
+ (colosseum = new Pin {
+ Type = PinType.Place,
+ Position = new Position (41.890202, 12.492049),
+ Label = "Colosseum",
+ Address = "Piazza del Colosseo, 00184 Rome, Province of Rome, Italy"
+ }),
+ (pantheon = new Pin {
+ Type = PinType.Place,
+ Position = new Position (41.898652, 12.476831),
+ Label = "Pantheon",
+ Address = "Piazza della Rotunda, 00186 Rome, Province of Rome, Italy"
+ }),
+ (chapel = new Pin {
+ Type = PinType.Place,
+ Position = new Position (41.903209, 12.454545),
+ Label = "Sistine Chapel",
+ Address = "Piazza della Rotunda, 00186 Rome, Province of Rome, Italy"
+ })
+ }
+ };
+
+ colosseum.Clicked += PinClicked;
+ pantheon.Clicked += PinClicked;
+ chapel.Clicked += PinClicked;
+ return map;
+ }
+
+ static void PinClicked (object sender, EventArgs e)
+ {
+ // yea!
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs b/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs
new file mode 100644
index 00000000..f8aba26b
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs
@@ -0,0 +1,40 @@
+using System;
+
+namespace Xamarin.Forms.Controls
+{
+ public class MasterDetailPageTabletPage : ContentPage
+ {
+ public MasterDetailPageTabletPage ()
+ {
+ Title = "MasterDetail MasterBehavior Gallery";
+
+ var btn = new Button { Text = "Default (old behavior)" };
+ btn.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.Default,null));
+
+ var btn1 = new Button { Text = "Default (old behavior) but always hide toolbar button" };
+ btn1.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.Default,false));
+
+ var btn2 = new Button { Text = "Popover - (always show it as a popover) but hide toolbar button" };
+ btn2.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.Popover,false));
+
+ //there's never a time when to real hide the master i think, use a normal page for that..
+ //what the user wants is out of the screen, maybe we need a better namming
+ var btn3 = new Button { Text = "Popover - (always show it as a popover)" };
+ btn3.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.Popover, null));
+
+ //we throw an exception here if you try to toggle it
+ var btn4 = new Button { Text = "Split - (always show it as splitview , toogle master always visible, throws expception)" };
+ btn4.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.Split, null));
+
+ var btn5 = new Button { Text = "SplitOnPortrait Portrait - (always show it as splitview in Portrait, throws expception)" };
+ btn5.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.SplitOnPortrait, null));
+
+ var btn6 = new Button { Text = "SplitOnLandscape Landscape - (always show it as splitview in Landscape, throws expception))" };
+ btn6.Clicked += async (sender, e) => await Navigation.PushModalAsync (new Issue1461Page (MasterBehavior.SplitOnLandscape, null));
+
+ Content = new StackLayout { Padding= new Thickness(0,20,0,0) , Children = { btn, btn1, btn2, btn6, btn3, btn4, btn5 }, Spacing = 20 };
+
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/MinimumSizeGallery.cs b/Xamarin.Forms.Controls/GalleryPages/MinimumSizeGallery.cs
new file mode 100644
index 00000000..1ad90574
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/MinimumSizeGallery.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class MinimumSizeGallery : ContentPage
+ {
+ public MinimumSizeGallery ()
+ {
+ Content = new StackLayout {
+ Children = {
+ new Button { Text = "Big Button", HeightRequest = 300 },
+ new TableView {
+ Intent = TableIntent.Settings,
+ Root = new TableRoot {
+ new TableSection ("SECTION 1") {
+ new TextCell { Text = "Cell 1", Detail = "Red Text", TextColor = Color.Red },
+ new TextCell { Text = "Detail Red", Detail = "Detail", DetailColor = Color.Red },
+ new TextCell { Text = "Cell 3" },
+ new TextCell { Text = "Cell 4" }
+ },
+ new TableSection ("Section 2") {
+ new TextCell { Text = "Cell 1" },
+ new TextCell { Text = "Cell 2" },
+ new TextCell { Text = "Cell 3" },
+ new TextCell { Text = "Cell 4" }
+ },
+ new TableSection ("Section 3") {
+ new TextCell { Text = "Cell 1" },
+ new TextCell { Text = "Cell 2" },
+ new TextCell { Text = "Cell 3" },
+ new TextCell { Text = "Cell 4" }
+ },
+ new TableSection ("Section 4") {
+ new TextCell { Text = "Cell 1" },
+ new TextCell { Text = "Cell 2" },
+ new TextCell { Text = "Cell 3" },
+ new TextCell { Text = "Cell 4 Last" }
+ }
+ }
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/MultiGallery.cs b/Xamarin.Forms.Controls/GalleryPages/MultiGallery.cs
new file mode 100644
index 00000000..02ceab08
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/MultiGallery.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class MultiGallery : ContentPage
+ {
+ public MultiGallery ()
+ {
+ var button = new Button {Text = "Toggle Nav Bar"};
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Children = {
+ button,
+ new Editor (),
+ new Entry (),
+ new Image {Source = ImageSource.FromFile ("cover1.jpg")},
+ new Label {Text = "Label"},
+ new ProgressBar (),
+ new ActivityIndicator (),
+ new Switch (),
+ new Stepper (),
+ new Slider (),
+ new ProgressBar (),
+ new ActivityIndicator (),
+ new Switch (),
+ new Stepper (),
+ new Slider ()
+ }
+ }
+ };
+
+ button.Clicked +=
+ (sender, args) => NavigationPage.SetHasNavigationBar (this, !NavigationPage.GetHasNavigationBar (this));
+
+ ToolbarItems.Add (new ToolbarItem ("Back", "bank.png", () => Navigation.PopAsync (), ToolbarItemOrder.Primary));
+ ToolbarItems.Add (new ToolbarItem ("It's", "bank.png", () => Navigation.PopAsync (), ToolbarItemOrder.Secondary));
+ ToolbarItems.Add (new ToolbarItem ("A", "bank.png", () => Navigation.PopAsync (), ToolbarItemOrder.Secondary));
+ ToolbarItems.Add (new ToolbarItem ("TARP!", "bank.png", () => Navigation.PopAsync (), ToolbarItemOrder.Secondary));
+ }
+
+ protected override void OnAppearing ()
+ {
+ Debug.WriteLine ("Appearing");
+ base.OnAppearing ();
+ }
+
+ protected override void OnDisappearing ()
+ {
+ Debug.WriteLine ("Disappearing");
+ base.OnDisappearing ();
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/NavigationBarGallery.cs b/Xamarin.Forms.Controls/GalleryPages/NavigationBarGallery.cs
new file mode 100644
index 00000000..dfbc342c
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/NavigationBarGallery.cs
@@ -0,0 +1,62 @@
+using System.Diagnostics;
+
+namespace Xamarin.Forms.Controls
+{
+ public class NavigationBarGallery : ContentPage
+ {
+ public NavigationBarGallery (NavigationPage rootNavPage)
+ {
+
+ int toggleBarTextColor = 0;
+ int toggleBarBackgroundColor = 0;
+
+ Content = new StackLayout {
+ Children = {
+ new Button {
+ Text = "Change BarTextColor",
+ Command = new Command (() => {
+ if (toggleBarTextColor % 2 == 0) {
+ rootNavPage.BarTextColor = Color.Teal;
+ } else {
+ rootNavPage.BarTextColor = Color.Default;
+ }
+ toggleBarTextColor++;
+ })
+ },
+ new Button {
+ Text = "Change BarBackgroundColor",
+ Command = new Command (() => {
+ if (toggleBarBackgroundColor % 2 == 0) {
+ rootNavPage.BarBackgroundColor = Color.Navy;
+ } else {
+ rootNavPage.BarBackgroundColor = Color.Default;
+ }
+ toggleBarBackgroundColor++;
+
+ })
+ },
+ new Button {
+ Text = "Change Both to default",
+ Command = new Command (() => {
+ rootNavPage.BarTextColor = Color.Default;
+ rootNavPage.BarBackgroundColor = Color.Default;
+ })
+ },
+ new Button {
+ Text = "Make sure Tint still works",
+ Command = new Command (() => {
+ rootNavPage.Tint = Color.Red;
+ })
+ },
+ new Button {
+ Text = "Black background, white text",
+ Command = new Command (() => {
+ rootNavPage.BarTextColor = Color.White;
+ rootNavPage.BarBackgroundColor = Color.Black;
+ })
+ }
+ }
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/NavigationMenuGallery.cs b/Xamarin.Forms.Controls/GalleryPages/NavigationMenuGallery.cs
new file mode 100644
index 00000000..d63745da
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/NavigationMenuGallery.cs
@@ -0,0 +1,38 @@
+using System.Diagnostics;
+
+namespace Xamarin.Forms.Controls
+{
+ public class NavigationMenuGallery : ContentPage
+ {
+ public NavigationMenuGallery ()
+ {
+ Content = new ScrollView {
+ Content = new NavigationMenu {
+ Targets = new[] {
+ new ContentPage {
+ Content =
+ new Label {
+ Text = "Test 1",
+ VerticalOptions = LayoutOptions.Center,
+ HorizontalOptions = LayoutOptions.Center
+ },
+ Title = "Testing 1",
+ Icon = "cover1.jpg"
+ },
+ new ContentPage { Content = new Label { Text = "Test 2" }, Title = "Testing 2", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 3" }, Title = "Testing 3", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 4" }, Title = "Testing 4", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 5" }, Title = "Testing 5", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 6" }, Title = "Testing 6", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 7" }, Title = "Testing 7", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 8" }, Title = "Testing 8", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 9" }, Title = "Testing 9", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 10" }, Title = "Testing 10", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 11" }, Title = "Testing 11", Icon = "cover1.jpg" },
+ new ContentPage { Content = new Label { Text = "Test 12" }, Title = "Testing 12", Icon = "cover1.jpg" }
+ }
+ }
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/GalleryPages/NavigationPropertiesGallery.cs b/Xamarin.Forms.Controls/GalleryPages/NavigationPropertiesGallery.cs
new file mode 100644
index 00000000..0628cfa8
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/NavigationPropertiesGallery.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class NavigationPropertiesGallery
+ : ContentPage
+ {
+ public NavigationPropertiesGallery ()
+ {
+ var noBack = new ContentPage {
+ Title = "No back button",
+ };
+ NavigationPage.SetHasBackButton (noBack, false);
+ var toggleBackButton = new Button { Text = "Toggle Back Button" };
+ toggleBackButton.Clicked += (sender, e) => {
+ var hasBack = NavigationPage.GetHasBackButton (noBack);
+ if (hasBack)
+ NavigationPage.SetHasBackButton (noBack, false);
+ else
+ NavigationPage.SetHasBackButton (noBack, true);
+ };
+ noBack.Content = toggleBackButton;
+
+
+ var noBar = new ContentPage {
+ Title = "No bar",
+ Content = new Label {
+ Text = "No bar content",
+ Style = Device.Styles.TitleStyle
+ }
+ };
+
+ var backTitle = new ContentPage {
+ Title = "Back button title"
+ };
+
+ NavigationPage.SetHasNavigationBar (noBar, false);
+
+ Content = new ListView {
+ ItemsSource = new[] {
+ noBack,
+ noBar,
+ backTitle
+ },
+
+ ItemTemplate = new DataTemplate (typeof(TextCell)) {
+ Bindings = {
+ { TextCell.TextProperty, new Binding ("Title") }
+ }
+ }
+ };
+
+ ((ListView) Content).ItemTapped += async (sender, args) => {
+ await Navigation.PushAsync ((Page) args.Item);
+ };
+
+ NavigationPage.SetBackButtonTitle (this, "Back Title");
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/OpenGLGallery.cs b/Xamarin.Forms.Controls/GalleryPages/OpenGLGallery.cs
new file mode 100644
index 00000000..bb5ce8ab
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/OpenGLGallery.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+#if HAVE_OPENTK
+using OpenTK.Graphics;
+using OpenTK.Graphics.ES20;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+#if HAVE_OPENTK
+ public class OpenGLGallery : ContentPage
+ {
+ float red, green, blue;
+
+ public OpenGLGallery ()
+ {
+ var view = new OpenGLView {HasRenderLoop = true};
+ var toggle = new Switch {IsToggled = true};
+ var button = new Button {Text = "Display"};
+
+ view.HeightRequest = 300;
+ view.WidthRequest = 300;
+
+ view.OnDisplay = r =>{
+ /*
+ if (!inited) {
+ var shader = GL.CreateShader (All.VertexShader);
+ int length = 0;
+ GL.ShaderSource (shader, 1, new string [] { "void main() { gl_FragColor = vec4(0.6, 1.0, 0.0, 1.0); }"}, ref length);
+ GL.CompileShader (shader);
+ int status = 0;
+ GL.GetShader (shader, All.CompileStatus, ref status);
+ if (status == 0) {
+ GL.DeleteShader (shader);
+ throw new Exception();
+ }
+
+ inited = true;
+ }
+ */
+ GL.ClearColor (red, green, blue, 1.0f);
+ GL.Clear ((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
+
+ red += 0.01f;
+ if (red >= 1.0f)
+ red -= 1.0f;
+ green += 0.02f;
+ if (green >= 1.0f)
+ green -= 1.0f;
+ blue += 0.03f;
+ if (blue >= 1.0f)
+ blue -= 1.0f;
+ };
+
+ toggle.Toggled += (s, a) => { view.HasRenderLoop = toggle.IsToggled; };
+ button.Activated += (s, a) => view.Display ();
+
+ var stack = new StackLayout {Padding = new Size (20, 20)};
+ stack.Add (view);
+ stack.Add (toggle);
+ stack.Add (button);
+
+ Content = stack;
+ }
+ }
+#endif
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/PickerGallery.cs b/Xamarin.Forms.Controls/GalleryPages/PickerGallery.cs
new file mode 100644
index 00000000..676c907a
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/PickerGallery.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class PickerGallery : ContentPage
+ {
+ public PickerGallery ()
+ {
+ var picker = new Picker {Title="Dismiss in one sec", Items = {"John", "Paul", "George", "Ringo"}};
+ picker.Focused += async (object sender, FocusEventArgs e) => {
+ await Task.Delay (1000);
+ picker.Unfocus ();
+ };
+
+ Label testLabel = new Label { Text = "", AutomationId="test", ClassId="test" };
+
+ Picker p1 = new Picker { Title = "Pick a number", Items = { "0", "1", "2", "3", "4", "5", "6" }};
+ p1.SelectedIndexChanged += (sender, e) => {
+ testLabel.Text = "Selected Index Changed";
+ };
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Padding = new Thickness (20, 20),
+ Children = {
+ new DatePicker (),
+ new TimePicker (),
+ new DatePicker { Format = "D" },
+ new TimePicker { Format = "T" },
+ new Picker {Title = "Set your favorite Beatle", Items = {"John", "Paul", "George", "Ringo"}},
+ new Picker {Title = "Set your favorite Stone", Items = {"Mick", "Keith", "Charlie", "Ronnie"}, SelectedIndex = 1},
+ new Picker {Title = "Pick", Items = {"Jason Smith", "Rui Marinho", "Eric Maupin", "Chris King"}, HorizontalOptions = LayoutOptions.CenterAndExpand},
+ picker,
+ testLabel,
+ p1
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ProgressBarGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ProgressBarGallery.cs
new file mode 100644
index 00000000..3190a3cf
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ProgressBarGallery.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ProgressBarGallery : ContentPage
+ {
+ readonly StackLayout _stack;
+
+ public ProgressBarGallery ()
+ {
+ _stack = new StackLayout ();
+
+ var normal = new ProgressBar {
+ Progress = 0.24
+ };
+
+ Content = _stack;
+
+ _stack.Children.Add (normal);
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs
new file mode 100644
index 00000000..1feaafe6
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class RelativeLayoutGallery : ContentPage
+ {
+ public RelativeLayoutGallery()
+ {
+ var layout = new RelativeLayout ();
+
+ var box1 = new ContentView {
+ BackgroundColor = Color.Gray,
+ Content = new Label {
+ Text = "0"
+ }
+ };
+
+ double padding = 10;
+ layout.Children.Add (box1, () => new Rectangle (((layout.Width + padding) % 60) / 2, padding, 50, 50));
+
+ var last = box1;
+ for (int i = 0; i < 200; i++) {
+ var relativeTo = last; // local copy
+ var box = new ContentView {
+ BackgroundColor = Color.Gray,
+ Content = new Label {
+ Text = (i+1).ToString ()
+ }
+ };
+
+ Func<View, bool> pastBounds = view => relativeTo.Bounds.Right + padding + relativeTo.Width > layout.Width;
+ layout.Children.Add (box, () => new Rectangle (pastBounds (relativeTo) ? box1.X : relativeTo.Bounds.Right + padding,
+ pastBounds (relativeTo) ? relativeTo.Bounds.Bottom + padding : relativeTo.Y,
+ relativeTo.Width,
+ relativeTo.Height));
+
+ last = box;
+ }
+
+ Content = new ScrollView {Content = layout, Padding = new Thickness(50)};
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ScaleRotate.cs b/Xamarin.Forms.Controls/GalleryPages/ScaleRotate.cs
new file mode 100644
index 00000000..e189f839
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ScaleRotate.cs
@@ -0,0 +1,157 @@
+using System;
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class ScaleRotate : ContentPage
+ {
+ public ScaleRotate()
+ {
+ Label label = new Label
+ {
+ Text = "SCALE AND\nROTATE",
+ HorizontalTextAlignment = TextAlignment.Center,
+ HorizontalOptions = LayoutOptions.Center,
+ VerticalOptions = LayoutOptions.CenterAndExpand
+ };
+
+ // Label and Slider for Scale property.
+ Label scaleSliderValue = new Label
+ {
+ VerticalTextAlignment = TextAlignment.Center
+ };
+ Grid.SetRow(scaleSliderValue, 0);
+ Grid.SetColumn(scaleSliderValue, 0);
+
+ Slider scaleSlider = new Slider
+ {
+ Maximum = 10
+ };
+ Grid.SetRow(scaleSlider, 0);
+ Grid.SetColumn(scaleSlider, 1);
+
+ // Set Bindings.
+ scaleSliderValue.BindingContext = scaleSlider;
+ scaleSliderValue.SetBinding(Label.TextProperty,
+ new Binding("Value", BindingMode.OneWay, null, null, "Scale = {0:F1}"));
+
+ scaleSlider.BindingContext = label;
+ scaleSlider.SetBinding(Slider.ValueProperty,
+ new Binding("Scale", BindingMode.TwoWay));
+
+ // Label and Slider for Rotation property.
+ Label rotationSliderValue = new Label
+ {
+ VerticalTextAlignment = TextAlignment.Center
+ };
+ Grid.SetRow(rotationSliderValue, 1);
+ Grid.SetColumn(rotationSliderValue, 0);
+
+ Slider rotationSlider = new Slider
+ {
+ Maximum = 360
+ };
+ Grid.SetRow(rotationSlider, 1);
+ Grid.SetColumn(rotationSlider, 1);
+
+ // Set Bindings.
+ rotationSliderValue.BindingContext = rotationSlider;
+ rotationSliderValue.SetBinding(Label.TextProperty,
+ new Binding("Value", BindingMode.OneWay, null, null, "Rotation = {0:F0}"));
+
+ rotationSlider.BindingContext = label;
+ rotationSlider.SetBinding(Slider.ValueProperty,
+ new Binding("Rotation", BindingMode.TwoWay));
+
+ // Label and Slider for AnchorX property.
+ Label anchorxStepperValue = new Label
+ {
+ VerticalTextAlignment = TextAlignment.Center
+ };
+ Grid.SetRow(anchorxStepperValue, 2);
+ Grid.SetColumn(anchorxStepperValue, 0);
+
+ Stepper anchorxStepper = new Stepper
+ {
+ Maximum = 2,
+ Minimum = -1,
+ Increment = 0.5
+ };
+ Grid.SetRow(anchorxStepper, 2);
+ Grid.SetColumn(anchorxStepper, 1);
+
+ // Set bindings.
+ anchorxStepperValue.BindingContext = anchorxStepper;
+ anchorxStepperValue.SetBinding(Label.TextProperty,
+ new Binding("Value", BindingMode.OneWay, null, null, "AnchorX = {0:F1}"));
+
+ anchorxStepper.BindingContext = label;
+ anchorxStepper.SetBinding(Stepper.ValueProperty,
+ new Binding("AnchorX", BindingMode.TwoWay));
+
+ // Label and Slider for AnchorY property.
+ Label anchoryStepperValue = new Label
+ {
+ VerticalTextAlignment = TextAlignment.Center
+ };
+ Grid.SetRow(anchoryStepperValue, 3);
+ Grid.SetColumn(anchoryStepperValue, 0);
+
+ Stepper anchoryStepper = new Stepper
+ {
+ Maximum = 2,
+ Minimum = -1,
+ Increment = 0.5
+ };
+ Grid.SetRow(anchoryStepper, 3);
+ Grid.SetColumn(anchoryStepper, 1);
+
+ // Set bindings.
+ anchoryStepperValue.BindingContext = anchoryStepper;
+ anchoryStepperValue.SetBinding(Label.TextProperty,
+ new Binding("Value", BindingMode.OneWay, null, null, "AnchorY = {0:F1}"));
+
+ anchoryStepper.BindingContext = label;
+ anchoryStepper.SetBinding(Stepper.ValueProperty,
+ new Binding("AnchorY", BindingMode.TwoWay));
+
+ // Assemble the page.
+ Content = new StackLayout
+ {
+ Children =
+ {
+ label,
+ new Grid
+ {
+ Padding = 10,
+ RowDefinitions =
+ {
+ new RowDefinition { Height = GridLength.Auto },
+ new RowDefinition { Height = GridLength.Auto },
+ new RowDefinition { Height = GridLength.Auto },
+ new RowDefinition { Height = GridLength.Auto },
+ },
+ ColumnDefinitions =
+ {
+ new ColumnDefinition { Width = GridLength.Auto },
+ new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)}
+ },
+ Children =
+ {
+ scaleSliderValue,
+ scaleSlider,
+ rotationSliderValue,
+ rotationSlider,
+ anchorxStepperValue,
+ anchorxStepper,
+ anchoryStepperValue,
+ anchoryStepper
+ }
+ }
+ }
+ };
+ }
+ }
+}
+
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/ScrollGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ScrollGallery.cs
new file mode 100644
index 00000000..cf00482d
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ScrollGallery.cs
@@ -0,0 +1,158 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ScrollGallery : ContentPage
+ {
+ readonly ScrollView _scrollview;
+ readonly StackLayout _stack;
+ ScrollOrientation _orientation;
+ List<Button> _buttons = new List<Button> ();
+ Button _toNavigateTo;
+ public ScrollGallery (ScrollOrientation orientation = ScrollOrientation.Vertical)
+ {
+ _orientation = orientation;
+ var root = new Grid ();
+ root.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
+ root.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
+ root.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
+ root.RowDefinitions.Add (new RowDefinition ());
+
+ var btnStack1 = new StackLayout { Orientation = StackOrientation.Horizontal };
+ var btnStack = new StackLayout { Orientation = StackOrientation.Horizontal };
+ var btn = new Button { Text = "Scroll to 100" };
+ var btn4 = new Button { Text = "Scroll to 100 no anim" };
+ var btn1 = new Button { Text = "Start" };
+ var btn2 = new Button { Text = "Center" };
+ var btn3 = new Button { Text = "End" };
+ var btn6 = new Button { Text = "MakeVisible", HorizontalOptions= LayoutOptions.CenterAndExpand, BackgroundColor = Color.Accent };
+
+ var label = new Label { Text = string.Format ("X: {0}, Y: {1}", 0, 0) };
+
+ root.Children.Add (label);
+ root.Children.Add (btnStack);
+ root.Children.Add (btnStack1);
+
+ btnStack.Children.Add (btn1);
+ btnStack.Children.Add (btn2);
+ btnStack.Children.Add (btn3);
+
+ btnStack1.Children.Add (btn);
+ btnStack1.Children.Add (btn4);
+
+ Grid.SetRow (btnStack, 1);
+ Grid.SetRow (btnStack1, 2);
+
+ var grid = new Grid ();
+ grid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto });
+ grid.RowDefinitions.Add (new RowDefinition ());
+ _stack = new StackLayout ();
+ Grid.SetRow (_stack, 1);
+ grid.Children.Add (btn6);
+ grid.Children.Add (_stack);
+ _scrollview = new ScrollView {
+ AutomationId="thescroller",
+ BackgroundColor = Color.Aqua,
+ Content = grid
+ };
+ root.Children.Add (_scrollview);
+ Grid.SetRow (_scrollview, 3);
+
+ _scrollview.Scrolled+= (object sender, ScrolledEventArgs e) => {
+ label.Text = string.Format ("X: {0}, Y: {1}", e.ScrollX, e.ScrollY);
+ };
+
+ btn.Clicked += async (object sender, EventArgs e) => {
+ switch (orientation) {
+ case ScrollOrientation.Horizontal:
+ await _scrollview.ScrollToAsync (100, 0, true);
+ break;
+ case ScrollOrientation.Vertical:
+ await _scrollview.ScrollToAsync (0, 100, true);
+ break;
+ case ScrollOrientation.Both:
+ await _scrollview.ScrollToAsync (100, 100, true);
+ break;
+ }
+ };
+ btn4.Clicked += async (object sender, EventArgs e) => {
+ switch (orientation) {
+ case ScrollOrientation.Horizontal:
+ await _scrollview.ScrollToAsync (100, 0, false);
+ break;
+ case ScrollOrientation.Vertical:
+ await _scrollview.ScrollToAsync (0, 100, false);
+ break;
+ case ScrollOrientation.Both:
+ await _scrollview.ScrollToAsync (100, 100, true);
+ break;
+ }
+ };
+
+ btn1.Clicked += async (object sender, EventArgs e) => {
+ await _scrollview.ScrollToAsync (_toNavigateTo, ScrollToPosition.Start, true);
+ };
+ btn2.Clicked += async (object sender, EventArgs e) => {
+ await _scrollview.ScrollToAsync (_toNavigateTo, ScrollToPosition.Center, true);
+ };
+ btn3.Clicked += async (object sender, EventArgs e) => {
+ await _scrollview.ScrollToAsync (_toNavigateTo, ScrollToPosition.End, true);
+ };
+ btn6.Clicked += async (object sender, EventArgs e) => {
+ await _scrollview.ScrollToAsync (_toNavigateTo, ScrollToPosition.MakeVisible, true);
+ };
+
+ _stack.Padding = new Size (20, 60);
+
+ PopulateStack (_stack);
+
+ _scrollview.Orientation = _orientation;
+
+ if (orientation == ScrollOrientation.Horizontal || orientation == ScrollOrientation.Both) {
+ _stack.Orientation = StackOrientation.Horizontal;
+ }
+
+ if (orientation == ScrollOrientation.Both) {
+ var stack2 = new StackLayout ();
+ PopulateStack (stack2);
+ _stack.Children.Add (stack2);
+ }
+
+ Content = root;
+ }
+
+ void PopulateStack (StackLayout stack)
+ {
+ for (int i = 0; i < 100; i++) {
+
+ var newButton = new Button { Text = "Foo Bar", AutomationId =string.Format ("btn_{0}", i) };
+ if (i == 49)
+ newButton.Text = "the before";
+
+ if (i == 50) {
+ newButton.Text = "the scrollto button";
+ newButton.BackgroundColor = Color.Yellow;
+ newButton.TextColor = Color.Black;
+ _toNavigateTo = newButton;
+ }
+ if (i == 51)
+ newButton.Text = "the after";
+ if (i == 53) {
+ newButton.Text = "the make visible from start";
+ newButton.Clicked += async (object sender, EventArgs e) => {
+ await _scrollview.ScrollToAsync (_toNavigateTo, ScrollToPosition.MakeVisible, true);
+ };
+ }
+
+ _buttons.Add (newButton);
+ stack.Children.Add (newButton);
+ }
+
+ stack.Children.Add (new Button { Text = "Foo Bottom" });
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/SearchBarGallery.cs b/Xamarin.Forms.Controls/GalleryPages/SearchBarGallery.cs
new file mode 100644
index 00000000..c0b91e7e
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/SearchBarGallery.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class SearchBarGallery : ContentPage
+ {
+ Label _searchQueryLabel;
+
+ public SearchBarGallery ()
+ {
+ _searchQueryLabel = new Label {
+ Text = "Search Query"
+ };
+
+ var textChangedLabel = new Label {
+ Text = ""
+ };
+
+ var numCharsTyped = 0;
+
+ var noPlaceholder = new SearchBar();
+ noPlaceholder.SearchButtonPressed += OnSearchBarPressed;
+ noPlaceholder.TextChanged += (sender, e) => {
+ numCharsTyped++;
+ textChangedLabel.Text = numCharsTyped.ToString ();
+ };
+
+ var normal = new SearchBar { Placeholder = "Normal" };
+ normal.SearchButtonPressed += OnSearchBarPressed;
+ normal.TextChanged += (sender, e) => {
+ numCharsTyped++;
+ textChangedLabel.Text = numCharsTyped.ToString ();
+ };
+
+ var activation = new SearchBar { Placeholder = "Activation" };
+ activation.SearchButtonPressed += OnSearchBarPressed;
+ activation.TextChanged += (sender, e) => {
+ numCharsTyped++;
+ textChangedLabel.Text = numCharsTyped.ToString ();
+ };
+
+ var nextPageButton = new Button {
+ Text = "More SearchBars",
+ Command = new Command (async () => await Navigation.PushAsync (new SearchBarGalleryPageTwo ()))
+ };
+
+ int i = 1;
+ activation.SearchButtonPressed += (sender, e) => {
+ activation.Text = "";
+ activation.Placeholder = "Activated " + i++.ToString ();
+ };
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Spacing = 0,
+ Children = {
+ noPlaceholder,
+ normal,
+ activation,
+ _searchQueryLabel,
+ textChangedLabel,
+ nextPageButton
+ }
+ }
+ };
+ }
+
+ void OnSearchBarPressed(object sender, EventArgs eventArgs)
+ {
+ var searchBar = (SearchBar)sender;
+ _searchQueryLabel.Text = searchBar.Text;
+ }
+ }
+
+ public class SearchBarGalleryPageTwo : ContentPage
+ {
+ Label _searchQueryLabel;
+
+ public SearchBarGalleryPageTwo ()
+ {
+ Title = "Search Bar Gallery Part 2";
+
+ _searchQueryLabel = new Label {
+ Text = "Search Query 2"
+ };
+
+ var disabled = new SearchBar { Placeholder = "Disabled", IsEnabled = false };
+ disabled.SearchButtonPressed += OnSearchBarPressed;
+ var transparent = new SearchBar { Placeholder = "Transparent", Opacity = 0.5 };
+ transparent.SearchButtonPressed += OnSearchBarPressed;
+
+ var toggleDisabledButton = new Button {
+ Text = "Toggle enabled",
+ Command = new Command (() => {
+ if (disabled.IsEnabled) {
+ disabled.IsEnabled = false;
+ disabled.Placeholder = "Disabled";
+ } else {
+ disabled.IsEnabled = true;
+ disabled.Placeholder = "Enabled";
+ }
+ })
+ };
+
+ Content = new ScrollView {
+ Content = new StackLayout {
+ Spacing = 0,
+ Children = {
+ disabled,
+ transparent,
+ _searchQueryLabel,
+ toggleDisabledButton
+ }
+ }
+ };
+ }
+
+ void OnSearchBarPressed(object sender, EventArgs eventArgs)
+ {
+ var searchBar = (SearchBar)sender;
+ _searchQueryLabel.Text = searchBar.Text;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/SettingsPage.cs b/Xamarin.Forms.Controls/GalleryPages/SettingsPage.cs
new file mode 100644
index 00000000..b60af114
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/SettingsPage.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class SettingsPage : ContentPage
+ {
+ SettingsScreen _settingsScreen;
+ public SettingsPage ()
+ {
+ _settingsScreen = new SettingsScreen ();
+ Content = _settingsScreen;
+ }
+ }
+
+ public class SettingsScreen : TableView
+ {
+ public SettingsScreen ()
+ {
+ Intent = TableIntent.Settings;
+ var cell = new TextCell { Text = "Coverflow", Detail = "Value 1" };
+
+ var boolCell = new SwitchCell { Text = "Off" };
+ boolCell.OnChanged += (sender, arg) => boolCell.Text = boolCell.On ? "On" : "Off";
+
+ var root = new TableRoot () {
+ new TableSection () {
+ cell,
+ new TextCell { Text = "Cell 2", Detail = "Value 2" },
+ new EntryCell {
+ Label = "Label",
+ Placeholder = "Placeholder 1",
+ HorizontalTextAlignment = TextAlignment.Center,
+ Keyboard = Keyboard.Numeric
+ },
+ new ImageCell { Text = "Hello", Detail = "World", ImageSource = "cover1.jpg" }
+ },
+ new TableSection ("Styles") {
+ boolCell,
+ new EntryCell {
+ Label = "Label2",
+ Placeholder = "Placeholder 2",
+ HorizontalTextAlignment = TextAlignment.Center,
+ Keyboard = Keyboard.Chat
+ },
+ },
+ new TableSection ("Custom Cells") {
+ new ViewCell { View = new Button (){ Text = "Hi" } },
+ }
+ };
+ Root = root;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/SliderGallery.cs b/Xamarin.Forms.Controls/GalleryPages/SliderGallery.cs
new file mode 100644
index 00000000..4fd9f20c
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/SliderGallery.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class SliderGallery : ContentPage
+ {
+ public SliderGallery ()
+ {
+ var normal = new Slider (20, 100, 20);
+ var disabled = new Slider (0, 1, 0);
+ var transparent = new Slider (0, 1, 0);
+ var valueLabel = new Label { Text = normal.Value.ToString () };
+
+ disabled.IsEnabled = false;
+ transparent.Opacity = .5;
+ normal.ValueChanged += (sender, e) => { valueLabel.Text = normal.Value.ToString (); };
+
+ Content = new StackLayout {
+ Padding = new Thickness (40),
+ Children = {
+ normal,
+ disabled,
+ transparent,
+ valueLabel
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs
new file mode 100644
index 00000000..b08b5f35
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class StackLayoutGallery : ContentPage
+ {
+ public StackLayoutGallery ()
+ {
+ Device.OnPlatform (iOS: () => {
+ if (Device.Idiom == TargetIdiom.Tablet) {
+ Padding = new Thickness (0, 0, 0, 60);
+ }
+ });
+
+ var stack = new StackLayout { Orientation = StackOrientation.Vertical };
+ Button b1 = new Button { Text = "Boring", HeightRequest = 500, MinimumHeightRequest = 50 };
+ Button b2 = new Button {
+ Text = "Exciting!",
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ HorizontalOptions = LayoutOptions.CenterAndExpand
+ };
+ Button b3 = new Button { Text = "Amazing!", VerticalOptions = LayoutOptions.FillAndExpand };
+ Button b4 = new Button { Text = "Meh", HeightRequest = 400, MinimumHeightRequest = 50 };
+ b1.Clicked += (sender, e) => {
+ b1.Text = "clicked1";
+ };
+ b2.Clicked += (sender, e) => {
+ b2.Text = "clicked2";
+ };
+ b3.Clicked += (sender, e) => {
+ b3.Text = "clicked3";
+ };
+ b4.Clicked += (sender, e) => {
+ b4.Text = "clicked4";
+ };
+ stack.Children.Add (b1);
+ stack.Children.Add (b2);
+ stack.Children.Add (b3);
+ stack.Children.Add (b4);
+ Content = stack;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/StepperGallery.cs b/Xamarin.Forms.Controls/GalleryPages/StepperGallery.cs
new file mode 100644
index 00000000..6da9bba4
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/StepperGallery.cs
@@ -0,0 +1,49 @@
+using System;
+
+namespace Xamarin.Forms.Controls
+{
+ public class StepperGallery : ContentPage
+ {
+ public StepperGallery ()
+ {
+ var stepper = new Stepper {
+ Minimum = 0,
+ Maximum = 100,
+ Increment = 10
+ };
+
+ var label = new Label {
+ Text = stepper.Value.ToString()
+ };
+
+ stepper.ValueChanged += (s, e) => {
+ label.Text = e.NewValue.ToString();
+ };
+
+ var stepperTwo = new Stepper {
+ Minimum = 0.0,
+ Maximum = 1.0,
+ Increment = 0.05
+ };
+
+ var labelTwo = new Label {
+ Text = stepperTwo.Value.ToString ()
+ };
+
+ stepperTwo.ValueChanged += (s, e) => {
+ labelTwo.Text = e.NewValue.ToString ();
+ };
+
+ Content = new StackLayout {
+ Padding = new Thickness (20),
+ Children = {
+ stepper,
+ label,
+ stepperTwo,
+ labelTwo
+ }
+ };
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/StyleGallery.cs b/Xamarin.Forms.Controls/GalleryPages/StyleGallery.cs
new file mode 100644
index 00000000..6ae2d846
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/StyleGallery.cs
@@ -0,0 +1,41 @@
+using System;
+
+namespace Xamarin.Forms.Controls
+{
+ public class StyleGallery:ContentPage
+ {
+ public StyleGallery ()
+ {
+ Content = new StackLayout {
+ Children = {
+ new Label {
+ Text = "This uses TitleStyle",
+ Style = Device.Styles.TitleStyle
+ },
+ new Label {
+ Text = "This uses SubtitleStyle",
+ Style = Device.Styles.SubtitleStyle
+ },
+ new Label {
+ Text = "This uses BodyStyle",
+ Style = Device.Styles.BodyStyle
+ },
+ new Label {
+ Text = "This uses CaptionStyle",
+ Style = Device.Styles.CaptionStyle
+ },
+ new Label {
+ Text = "This uses a custom style inherited dynamically from SubtitleStyle",
+ Style = new Style (typeof(Label)) {
+ BaseResourceKey = Device.Styles.SubtitleStyleKey,
+ Setters = {
+ new Setter {Property = Label.TextColorProperty, Value = Color.Pink}
+ }
+ }
+ },
+ }
+ };
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml b/Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml
new file mode 100644
index 00000000..524db152
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Controls.StyleXamlGallery">
+<ContentPage.Resources>
+ <ResourceDictionary>
+ <Style x:Key="customStyle" TargetType="Label" BaseResourceKey="SubtitleStyle">
+ <Setter Property="Label.TextColor" Value="Color.Pink"/>
+ </Style>
+ </ResourceDictionary>
+</ContentPage.Resources>
+ <StackLayout>
+ <Label Text="This uses TitleStyle" Style="{DynamicResource TitleStyle}"/>
+ <Label Text="This uses SubtitleStyle" Style="{DynamicResource SubtitleStyle}"/>
+ <Label Text="This uses BodyStyle" Style="{DynamicResource BodyStyle}"/>
+ <Label Text="This uses CaptionStyle" Style="{DynamicResource CaptionStyle}"/>
+ <Label Text="This uses a custom style inherited from SubtitleStyle" Style="{StaticResource customStyle}"/>
+ </StackLayout>
+</ContentPage>
diff --git a/Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml.cs b/Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml.cs
new file mode 100644
index 00000000..39837222
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/StyleXamlGallery.xaml.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Controls
+{
+ public partial class StyleXamlGallery : ContentPage
+ {
+ public StyleXamlGallery ()
+ {
+ InitializeComponent ();
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/SwitchGallery.cs b/Xamarin.Forms.Controls/GalleryPages/SwitchGallery.cs
new file mode 100644
index 00000000..efdf623b
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/SwitchGallery.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class SwitchGallery : ContentPage
+ {
+ public SwitchGallery ()
+ {
+ var testLabel = new Label {
+ Text = "Test Label"
+ };
+
+ var normal = new Switch { IsToggled = true };
+ var disabled = new Switch ();
+ var transparent = new Switch ();
+ var stepper = new Stepper ();
+
+ normal.Toggled += (sender, e) => {
+ testLabel.Text = "Toggled normal switch";
+ };
+
+ disabled.Toggled += (sender, e) => {
+ testLabel.Text = "Toggled disabled switch (magic)";
+ };
+
+ transparent.Toggled += (sender, e) => {
+ testLabel.Text = "Toggled transparent switch";
+ };
+
+ stepper.ValueChanged += (sender, e) => {
+ testLabel.Text = stepper.Value.ToString ();
+ };
+
+ disabled.IsEnabled = false;
+ transparent.Opacity = 0.5;
+
+ Content = new StackLayout {
+ Padding = new Thickness (20),
+ Children = {
+ testLabel,
+ normal,
+ disabled,
+ transparent,
+ stepper,
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/TableViewGallery.cs b/Xamarin.Forms.Controls/GalleryPages/TableViewGallery.cs
new file mode 100644
index 00000000..92e5c1cc
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/TableViewGallery.cs
@@ -0,0 +1,24 @@
+namespace Xamarin.Forms.Controls
+{
+ internal class TableViewGallery : ContentPage
+ {
+ public TableViewGallery () {
+
+ var section = new TableSection ("Section One") {
+ new ViewCell { View = new Label { Text = "View Cell 1" } },
+ new ViewCell { View = new Label { Text = "View Cell 2" } }
+ };
+
+ var root = new TableRoot ("Table") {
+ section
+ };
+
+ var tableLayout = new TableView {
+ Root = root,
+ RowHeight = 100
+ };
+
+ Content = tableLayout;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/TemplatedCarouselGallery.cs b/Xamarin.Forms.Controls/GalleryPages/TemplatedCarouselGallery.cs
new file mode 100644
index 00000000..2d9cfe11
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/TemplatedCarouselGallery.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class TemplatedCarouselGallery
+ : CarouselPage
+ {
+ ObservableCollection<Item> _items;
+ int _count = 0;
+
+ public TemplatedCarouselGallery()
+ {
+ NavigationPage.SetHasNavigationBar (this, false);
+
+ _items = new ObservableCollection<Item> {
+ CreateItem(),
+ CreateItem(),
+ };
+
+ ItemsSource = _items;
+
+ ItemTemplate = new DataTemplate (() => {
+ var page = new ContentPage ();
+
+ page.Padding = new Thickness (0,30,0,0);
+ page.SetBinding (TitleProperty, "Title");
+
+ var layout = new StackLayout { Spacing = 0 };
+
+ var label = new Label();
+ label.SetBinding (Label.TextProperty, "Content");
+ layout.Children.Add (label);
+
+ var swipeHereLabel = new Label {
+ Text = "Swipe Here",
+ HeightRequest = 40
+ };
+
+ layout.Children.Add (swipeHereLabel);
+
+ var add = new Button ();
+ add.SetBinding (Button.TextProperty, "InsertTabText");
+ add.Clicked += (sender, args) => _items.Insert (_items.IndexOf ((Item)add.BindingContext) + 1, CreateItem());
+ layout.Children.Add (add);
+
+ var change = new Button ();
+ change.SetBinding (Button.TextProperty, "ChangeTitleText");
+ change.Clicked += (sender, args) => ((Item) change.BindingContext).Title = (new Random().Next().ToString());
+ layout.Children.Add (change);
+
+ var remove = new Button ();
+ remove.SetBinding (Button.TextProperty, "RemoveTabText");
+ remove.Clicked += (sender, args) => _items.Remove ((Item)remove.BindingContext);
+ layout.Children.Add (remove);
+
+ var reset = new Button ();
+ reset.SetBinding (Button.TextProperty, "ResetAllTabsText");
+ reset.Clicked += (sender, args) => {
+ _count = 0;
+ ItemsSource = _items = new ObservableCollection<Item> { CreateItem(), CreateItem() };
+ };
+ layout.Children.Add (reset);
+
+ var nextPage = new Button ();
+ nextPage.SetBinding (Button.TextProperty, "NextPageText");
+ nextPage.Clicked += (sender, args) => {
+ int index = _items.IndexOf ((Item) nextPage.BindingContext) + 1;
+ if (index == _items.Count)
+ index = 0;
+
+ SelectedItem = _items[index];
+ };
+ layout.Children.Add (nextPage);
+
+ var delayReset = new Button { Text = "Delayed reset" };
+ delayReset.SetBinding (Button.TextProperty, "DelayedResetText");
+ delayReset.Clicked += (sender, args) => {
+ ItemsSource = null;
+
+ Task.Delay (5000).ContinueWith (t => {
+ _count = 0;
+ ItemsSource = _items = new ObservableCollection<Item> { CreateItem(), CreateItem() };
+ }, TaskScheduler.FromCurrentSynchronizationContext());
+ };
+
+ layout.Children.Add (delayReset);
+
+ page.Content = new ScrollView {
+ Padding = new Thickness (60, 0),
+ Content = layout
+ };
+ return page;
+ });
+ }
+
+ Item CreateItem()
+ {
+ int x = _count++;
+ return new Item {
+ Title = "Page " + x,
+ Content = "Lorem ipsum dolor sit amet #" + x,
+ InsertTabText = "Insert Tab: " + x,
+ ChangeTitleText = "Change title: " + x,
+ MoveTabText = "Move Tab: " + x,
+ RemoveTabText = "Remove Tab: " + x,
+ ResetAllTabsText = "Reset all tabs: " + x,
+ NextPageText = "Next Page: " + x,
+ DelayedResetText = "Delayed reset: " + x
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/TemplatedTabbedGallery.cs b/Xamarin.Forms.Controls/GalleryPages/TemplatedTabbedGallery.cs
new file mode 100644
index 00000000..014b77e5
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/TemplatedTabbedGallery.cs
@@ -0,0 +1,169 @@
+using System;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ internal class Item
+ : INotifyPropertyChanged
+ {
+ string _title;
+ string _content;
+ public string InsertTabText { get; set; }
+ public string ChangeTitleText { get; set; }
+ public string MoveTabText { get; set; }
+ public string RemoveTabText { get; set; }
+ public string ResetAllTabsText { get; set; }
+ public string NextPageText { get; set; }
+ public string DelayedResetText { get; set; }
+
+ public string Icon { get; set; }
+
+ public string Title
+ {
+ get { return _title; }
+ set
+ {
+ if (_title == value)
+ return;
+
+ _title = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public string Content
+ {
+ get { return _content; }
+ set
+ {
+ if (_content == value)
+ return;
+
+ _content = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged ([CallerMemberName] string propertyName = null)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ handler (this, new PropertyChangedEventArgs (propertyName));
+ }
+ }
+
+ internal class TemplatedTabbedGallery : TabbedPage
+ {
+ ObservableCollection<Item> _items;
+ int _count = 0;
+
+ public TemplatedTabbedGallery()
+ {
+ Title = "Templated Tabbed Gallery";
+ _items = new ObservableCollection<Item> {
+ CreateItem(),
+ CreateItem()
+ };
+
+ ItemsSource = _items;
+
+ ItemTemplate = new DataTemplate (() => {
+ var page = new ContentPage();
+ page.SetBinding (TitleProperty, "Title");
+ page.SetBinding (IconProperty, "Icon");
+
+ var layout = new StackLayout();
+
+ var label = new Label();
+ label.SetBinding (Label.TextProperty, "Content");
+ layout.Children.Add (label);
+
+ var add = new Button ();
+ add.SetBinding (Button.TextProperty, "InsertTabText");
+ add.Clicked += (sender, args) => _items.Insert (_items.IndexOf ((Item)add.BindingContext) + 1, CreateItem());
+ layout.Children.Add (add);
+
+ var titleNum = 0;
+ var change = new Button ();
+ change.SetBinding (Button.TextProperty, "ChangeTitleText");
+ change.Clicked += (sender, args) => ((Item) change.BindingContext).Title = ("Title: " + titleNum++);
+ layout.Children.Add (change);
+
+ var move = new Button ();
+ move.SetBinding (Button.TextProperty, "MoveTabText");
+ move.Clicked += (sender, args) => {
+ int originalIndex = _items.IndexOf ((Item) add.BindingContext);
+ int index = originalIndex + 1;
+ if (index == _items.Count)
+ index = 0;
+
+ _items.Move (originalIndex, index);
+ };
+ layout.Children.Add (move);
+
+ var remove = new Button ();
+ remove.SetBinding (Button.TextProperty, "RemoveTabText");
+ remove.Clicked += (sender, args) => {
+ if (_items.Count == 0) {
+ layout.Children.Add (new Label {
+ Text = "No more tabs"
+ });
+ }
+ _items.Remove ((Item)remove.BindingContext);
+ };
+ layout.Children.Add (remove);
+
+ var reset = new Button ();
+ reset.SetBinding (Button.TextProperty, "ResetAllTabsText");
+ reset.Clicked += (sender, args) => {
+ _count = 0;
+ ItemsSource = _items = new ObservableCollection<Item> { CreateItem(), CreateItem() };
+ };
+ layout.Children.Add (reset);
+
+ var nextPage = new Button ();
+ nextPage.SetBinding (Button.TextProperty, "NextPageText");
+ nextPage.Clicked += (sender, args) => {
+ int index = _items.IndexOf ((Item) nextPage.BindingContext) + 1;
+ if (index == _items.Count)
+ index = 0;
+
+ SelectedItem = _items[index];
+ };
+ layout.Children.Add (nextPage);
+
+ page.Content = new ScrollView {
+ Padding = new Thickness (20, 0),
+ Content = layout
+ };
+
+ return page;
+ });
+ }
+
+ Item CreateItem()
+ {
+ int x = _count++;
+ var item = new Item {
+ Title = "Page " + x,
+ Content = "Lorem ipsum dolor sit amet #" + x ,
+ InsertTabText = "Insert Tab: " + x,
+ ChangeTitleText = "Change title: " + x,
+ MoveTabText = "Move Tab: " + x,
+ RemoveTabText = "Remove Tab: " + x,
+ ResetAllTabsText = "Reset all tabs: " + x,
+ NextPageText = "Next Page: " + x
+ };
+
+ if (x == 0)
+ item.Icon = "bank.png";
+
+ return item;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/ToolbarGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ToolbarGallery.cs
new file mode 100644
index 00000000..b2be5f02
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ToolbarGallery.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class ToolbarGallery : ContentPage
+ {
+ readonly Toolbar _toolbar;
+ readonly StackLayout _stack;
+
+ public ToolbarGallery ()
+ {
+ var label = new Label {
+ Text = "Click the toolbar"
+ };
+
+ Content = _stack = new StackLayout ();
+ _stack.Children.Add (label);
+
+ foreach (string name in new[] { "One", "Two", "Three", "Four" }) {
+ var toolbarItem = new ToolbarItem (name, null, delegate {
+ label.Text = "Activated: " + name;
+ }, ToolbarItemOrder.Secondary);
+ ToolbarItems.Add (toolbarItem);
+ }
+
+ var imagePrimaryItem = new ToolbarItem (null, "menuIcon.png", () => label.Text = "Activated: Primary Image 1", ToolbarItemOrder.Primary);
+ var imagePrimaryItemWithTitle = new ToolbarItem ("Primary", "menuIcon.png", () => label.Text = "Activated: Primary Image 2", ToolbarItemOrder.Primary);
+ var imageItem = new ToolbarItem (null, "seth.png", () => label.Text = "Activated: Secondary Image 1", ToolbarItemOrder.Secondary);
+ var imageItemWithTitle = new ToolbarItem ("Secondary", "seth.png", () => label.Text = "Activated: Secondary Image 2", ToolbarItemOrder.Secondary);
+ ToolbarItems.Add (imagePrimaryItem);
+ ToolbarItems.Add (imagePrimaryItemWithTitle);
+ ToolbarItems.Add (imageItem);
+ ToolbarItems.Add (imageItemWithTitle);
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/UnevenListGallery.cs b/Xamarin.Forms.Controls/GalleryPages/UnevenListGallery.cs
new file mode 100644
index 00000000..1c8b16c4
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/UnevenListGallery.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class UnevenListGallery : ContentPage
+ {
+ public UnevenListGallery ()
+ {
+ Padding = new Thickness (0, 20, 0, 0);
+
+ var list = new ListView {
+ HasUnevenRows = true
+ };
+
+ bool next = true;
+ list.ItemTemplate = new DataTemplate (() => {
+ bool tall = next;
+ next = !next;
+
+ var cell = new TextCell {
+ Height = (tall) ? 88 : 44
+ };
+
+ cell.SetBinding (TextCell.TextProperty, ".");
+ return cell;
+ });
+
+ list.ItemsSource = new[] { "Tall", "Short", "Tall", "Short" };
+
+ var listViewCellDynamicHeight = new ListView {
+ HasUnevenRows = true,
+ AutomationId= "unevenCellListGalleryDynamic"
+ };
+
+ listViewCellDynamicHeight.ItemsSource = new [] {
+ @"That Flesh is heir to? 'Tis a consummation
+Devoutly to be wished. To die, to sleep,
+To sleep, perchance to Dream; Aye, there's the rub,
+For in that sleep of death, what dreams may come,That Flesh is heir to? 'Tis a consummation
+Devoutly to be wished. To die, to sleep,
+To sleep, perchance to Dream; Aye, there's the rub,
+For in that sleep of death, what dreams may come",
+ };
+
+ listViewCellDynamicHeight.ItemTemplate = new DataTemplate (typeof(UnevenRowsCell));
+
+ listViewCellDynamicHeight.ItemTapped += (sender, e) => {
+ if (e == null)
+ return; // has been set to null, do not 'process' tapped event
+ ((ListView)sender).SelectedItem = null; // de-select the row
+ };
+
+ var grd = new Grid ();
+
+ grd.RowDefinitions.Add (new RowDefinition ());
+ grd.RowDefinitions.Add (new RowDefinition ());
+
+ grd.Children.Add (listViewCellDynamicHeight);
+ grd.Children.Add (list);
+
+ Grid.SetRow (list, 1);
+
+ Content = grd;
+ }
+
+ public class UnevenRowsCell : ViewCell
+ {
+ public UnevenRowsCell ()
+ {
+ var label1 = new Label {
+ Text = "Label 1",
+ FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label))
+ };
+ label1.SetBinding (Label.TextProperty, new Binding ("."));
+
+ View = new StackLayout {
+ Orientation = StackOrientation.Vertical,
+ VerticalOptions = LayoutOptions.StartAndExpand,
+ Padding = new Thickness (15, 5, 5, 5),
+ Children = { label1 }
+ };
+ }
+ // This is the code used before and still works by setting the height of the cell
+ // const int avgCharsInRow = 35;
+ // const int defaultHeight = 44;
+ // const int extraLineHeight = 20;
+ // protected override void OnBindingContextChanged ()
+ // {
+ // base.OnBindingContextChanged ();
+ //
+ // if (Device.OS == TargetPlatform.iOS) {
+ // var text = (string)BindingContext;
+ //
+ // var len = text.Length;
+ //
+ // if (len < (avgCharsInRow * 2)) {
+ // // fits in one cell
+ // Height = defaultHeight;
+ // } else {
+ // len = len - (avgCharsInRow * 2);
+ // var extraRows = len / 35;
+ // Height = defaultHeight + extraRows * extraLineHeight;
+ // }
+ // }
+ // }
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/WebViewGallery.cs b/Xamarin.Forms.Controls/GalleryPages/WebViewGallery.cs
new file mode 100644
index 00000000..c39e7777
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/WebViewGallery.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class WebViewGallery : ContentPage
+ {
+ class ViewModel
+ {
+ public string Html { get; set; } = "<html><body><p>This is a WebView!</p></body></html>";
+
+ public string Url { get; set; } = "http://xamarin.com";
+
+ }
+
+ public WebViewGallery ()
+ {
+ var htmlWebView = new WebView {
+ HeightRequest = 40,
+ //Source = new HtmlWebViewSource {Html ="<html><body><p>This is a WebView!</p></body></html>"}
+ };
+ var urlWebView = new WebView {
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ //Source = new UrlWebViewSource {Url = "http://xamarin.com/"}
+ };
+
+ var htmlSource = new HtmlWebViewSource ();
+ htmlSource.SetBinding (HtmlWebViewSource.HtmlProperty, "HTML");
+ htmlWebView.Source = htmlSource;
+
+ var urlSource = new UrlWebViewSource ();
+ urlSource.SetBinding (UrlWebViewSource.UrlProperty, "URL");
+ urlWebView.Source = urlSource;
+
+ var viewModel = new ViewModel ();
+ BindingContext = viewModel;
+
+ Content = new StackLayout {
+ Padding = new Size (20, 20),
+ Children = {
+ htmlWebView,
+ urlWebView
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml b/Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml
new file mode 100644
index 00000000..bbd6e334
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Controls.XamlPage">
+ <Label Text="Hello, Xaml" VerticalOptions="Center" HorizontalOptions="CenterAndExpand"/>
+</ContentPage>
diff --git a/Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml.cs b/Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml.cs
new file mode 100644
index 00000000..636ef608
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/XamlPage.xaml.cs
@@ -0,0 +1,13 @@
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Controls
+{
+ public partial class XamlPage : ContentPage
+ {
+ public XamlPage ()
+ {
+ InitializeComponent ();
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Controls/GalleryPages/crimson.jpg b/Xamarin.Forms.Controls/GalleryPages/crimson.jpg
new file mode 100644
index 00000000..3db7bb21
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/crimson.jpg
Binary files differ