summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/CoreGalleryPages
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls/CoreGalleryPages')
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/ActivityIndicatorCoreGalleryPage.cs39
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/ButtonCoreGalleryPage.cs106
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/CoreBoxViewGalleryPage.cs37
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/CoreGalleryPage.cs185
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/DatePickerCoreGalleryPage.cs34
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/EditorCoreGalleryPage.cs51
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/EntryCoreGalleryPage.cs92
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/FrameCoreGalleryPage.cs36
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/ImageCoreGalleryPage.cs56
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/KeyboardCoreGalleryPage.cs49
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/LabelCoreGalleryPage.cs158
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/ListViewCoreGalleryPage.cs268
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/OpenGLViewCoreGalleryPage.cs16
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/PickerCoreGalleryPage.cs35
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/ProgressBarCoreGalleryPage.cs27
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/SearchBarCoreGalleryPage.cs89
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/SliderCoreGalleryPage.cs29
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/StepperCoreGalleryPage.cs29
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/SwitchCoreGalleryPage.cs25
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/TableViewCoreGalleryPage.cs16
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/TimePickerCoreGalleryPage.cs24
-rw-r--r--Xamarin.Forms.Controls/CoreGalleryPages/WebViewCoreGalleryPage.cs62
22 files changed, 1463 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/ActivityIndicatorCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/ActivityIndicatorCoreGalleryPage.cs
new file mode 100644
index 00000000..8265cf74
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/ActivityIndicatorCoreGalleryPage.cs
@@ -0,0 +1,39 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class ActivityIndicatorCoreGalleryPage : CoreGalleryPage<ActivityIndicator>
+ {
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return true; }
+ }
+
+ protected override void InitializeElement (ActivityIndicator element)
+ {
+ element.IsRunning = true;
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var colorContainer = new ViewContainer<ActivityIndicator> (Test.ActivityIndicator.Color, new ActivityIndicator {
+ Color = Color.Lime,
+ IsRunning = true
+
+ });
+
+ var isRunningContainer = new StateViewContainer<ActivityIndicator> (Test.ActivityIndicator.IsRunning, new ActivityIndicator {
+ IsRunning = true
+ });
+
+ isRunningContainer.StateChangeButton.Clicked += (sender, args) => {
+ isRunningContainer.View.IsRunning = !isRunningContainer.View.IsRunning;
+ };
+
+ Add (colorContainer);
+ Add (isRunningContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/ButtonCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/ButtonCoreGalleryPage.cs
new file mode 100644
index 00000000..65aa6fa3
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/ButtonCoreGalleryPage.cs
@@ -0,0 +1,106 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class ButtonCoreGalleryPage : CoreGalleryPage<Button>
+ {
+ protected override bool SupportsTapGestureRecognizer {
+ get { return false; }
+ }
+
+ protected override bool SupportsFocus {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (Button element)
+ {
+ element.Text = "Button";
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ IsEnabledStateViewContainer.View.Clicked += (sender, args) => IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)";
+
+ var borderButtonContainer = new ViewContainer<Button> (Test.Button.BorderColor,
+ new Button {
+ Text = "BorderColor",
+ BackgroundColor = Color.Transparent,
+ BorderColor = Color.Red,
+ BorderWidth = 1,
+ }
+ );
+
+ var borderRadiusContainer = new ViewContainer<Button> (Test.Button.BorderRadius,
+ new Button {
+ Text = "BorderRadius",
+ BackgroundColor = Color.Transparent,
+ BorderColor = Color.Red,
+ BorderRadius = 20,
+ BorderWidth = 1,
+ }
+ );
+
+ var borderWidthContainer = new ViewContainer<Button> (Test.Button.BorderWidth,
+ new Button {
+ Text = "BorderWidth",
+ BackgroundColor = Color.Transparent,
+ BorderColor = Color.Red,
+ BorderWidth = 15,
+ }
+ );
+
+ var clickedContainer = new EventViewContainer<Button> (Test.Button.Clicked,
+ new Button {
+ Text = "Clicked"
+ }
+ );
+ clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired ();
+
+ var commandContainer = new ViewContainer<Button> (Test.Button.Command,
+ new Button {
+ Text = "Command",
+ Command = new Command (() => DisplayActionSheet ("Hello Command", "Cancel", "Destroy"))
+ }
+ );
+
+ var fontContainer = new ViewContainer<Button> (Test.Button.Font,
+ new Button {
+ Text = "Font",
+ Font = Font.SystemFontOfSize (NamedSize.Large, FontAttributes.Bold)
+ }
+ );
+
+ var imageContainer = new ViewContainer<Button> (Test.Button.Image,
+ new Button {
+ Text = "Image",
+ Image = new FileImageSource { File = "bank.png" }
+ }
+ )
+ ;
+ var textContainer = new ViewContainer<Button> (Test.Button.Text,
+ new Button {
+ Text = "Text"
+ }
+ );
+
+ var textColorContainer = new ViewContainer<Button> (Test.Button.TextColor,
+ new Button {
+ Text = "TextColor", TextColor = Color.Pink
+ }
+ );
+
+ Add (borderButtonContainer);
+ Add (borderRadiusContainer);
+ Add (borderWidthContainer);
+ Add (clickedContainer);
+ Add (commandContainer);
+ Add (fontContainer);
+ Add (imageContainer);
+ Add (textContainer);
+ Add (textColorContainer);
+ //stackLayout.Children.Add (textColorContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/CoreBoxViewGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/CoreBoxViewGalleryPage.cs
new file mode 100644
index 00000000..57ceaf44
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/CoreBoxViewGalleryPage.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Threading;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class CoreBoxViewGalleryPage : CoreGalleryPage<BoxView>
+ {
+ static readonly object SyncLock = new object ();
+ static readonly Random Rand = new Random ();
+
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (BoxView element)
+ {
+ lock (SyncLock) {
+ var red = Rand.NextDouble ();
+ var green = Rand.NextDouble ();
+ var blue = Rand.NextDouble ();
+ element.Color = new Color (red, green, blue);
+ }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var colorContainer = new ViewContainer<BoxView> (Test.BoxView.Color, new BoxView { Color = Color.Pink });
+
+ Add (colorContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/CoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/CoreGalleryPage.cs
new file mode 100644
index 00000000..41b3a796
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/CoreGalleryPage.cs
@@ -0,0 +1,185 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Threading;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class CoreGalleryPage<T> : ContentPage
+ where T : View, new ()
+ {
+ List<View> _views;
+ int _currentIndex;
+ Picker _picker;
+ StackLayout _moveNextStack;
+
+ ViewContainer<T> _backgroundColorViewContainer;
+ ViewContainer<T> _opacityViewContainer;
+ ViewContainer<T> _rotationViewContainer;
+ ViewContainer<T> _rotationXViewContainer;
+ ViewContainer<T> _rotationYViewContainer;
+ ViewContainer<T> _scaleViewContainer;
+ ViewContainer<T> _translationXViewContainer;
+ ViewContainer<T> _translationYViewContainer;
+
+ StateViewContainer<T> _focusStateViewContainer;
+ StateViewContainer<T> _isFocusedStateViewContainer;
+ StateViewContainer<T> _isVisibleStateViewContainer;
+
+ EventViewContainer<T> _gestureRecognizerEventViewContainer;
+ EventViewContainer<T> _focusedEventViewContainer;
+ EventViewContainer<T> _unfocusedEventViewContainer;
+
+ LayeredViewContainer<T> _inputTransparentViewContainer;
+
+ protected StateViewContainer<T> IsEnabledStateViewContainer { get; private set; }
+
+ protected StackLayout Layout { get; private set; }
+
+ internal CoreGalleryPage ()
+ {
+ Layout = new StackLayout {
+ Padding = new Thickness (20)
+ };
+
+ var modalDismissButton = new Button () {
+ Text = "Dismiss Page",
+ Command = new Command (async () => await Navigation.PopModalAsync ())
+ };
+ Layout.Children.Add (modalDismissButton);
+
+ Build (Layout);
+
+ Content = new ScrollView { AutomationId = "GalleryScrollView", Content = Layout };
+
+ }
+
+ protected virtual void InitializeElement (T element) {}
+
+ protected virtual void Build (StackLayout stackLayout)
+ {
+ var isFocusedView = new T ();
+ isFocusedView.SetValueCore (IsFocusedPropertyKey, true);
+
+ var viewContainers = new[] {
+ _isFocusedStateViewContainer = new StateViewContainer<T> (Test.VisualElement.IsFocused, isFocusedView),
+ _backgroundColorViewContainer = new ViewContainer<T> (Test.VisualElement.BackgroundColor, new T { BackgroundColor = Color.Blue }),
+ _focusStateViewContainer = new StateViewContainer<T> (Test.VisualElement.Focus, new T ()),
+ _gestureRecognizerEventViewContainer = new EventViewContainer<T> (Test.View.GestureRecognizers, new T ()),
+ _inputTransparentViewContainer = new LayeredViewContainer<T> (Test.VisualElement.InputTransparent, new T { InputTransparent = true }),
+ IsEnabledStateViewContainer = new StateViewContainer<T> (Test.VisualElement.IsEnabled, new T { IsEnabled = true }),
+ _focusedEventViewContainer = new EventViewContainer<T> (Test.VisualElement.Focused, new T ()),
+ _unfocusedEventViewContainer = new EventViewContainer<T> (Test.VisualElement.Unfocused, new T ()),
+ _isVisibleStateViewContainer = new StateViewContainer<T> (Test.VisualElement.IsVisible, new T { IsVisible = true }),
+ _opacityViewContainer = new ViewContainer<T> (Test.VisualElement.Opacity, new T { Opacity = 0.5 }),
+ _rotationViewContainer = new ViewContainer<T> (Test.VisualElement.Rotation, new T { Rotation = 10 }),
+ _rotationXViewContainer = new ViewContainer<T> (Test.VisualElement.RotationX, new T { RotationX = 33 }),
+ _rotationYViewContainer = new ViewContainer<T> (Test.VisualElement.RotationY, new T { RotationY = 10 }),
+ _scaleViewContainer = new ViewContainer<T> (Test.VisualElement.Scale, new T { Scale = 0.5 }),
+ _translationXViewContainer = new ViewContainer<T> (Test.VisualElement.TranslationX, new T { TranslationX = 30 }),
+ _translationYViewContainer = new ViewContainer<T> (Test.VisualElement.TranslationY, new T { TranslationY = 30 }),
+ };
+
+ // Set state
+ IsEnabledStateViewContainer.StateChangeButton.Command = new Command (() => {
+ IsEnabledStateViewContainer.View.IsEnabled = !IsEnabledStateViewContainer.View.IsEnabled;
+ });
+ _isVisibleStateViewContainer.StateChangeButton.Command = new Command (() => {
+ _isVisibleStateViewContainer.View.IsVisible = !_isVisibleStateViewContainer.View.IsVisible;
+ });
+
+ _focusStateViewContainer.StateChangeButton.Command = new Command (() => {
+ if (_focusStateViewContainer.View.IsFocused) {
+ _focusStateViewContainer.View.Unfocus ();
+ } else {
+ _focusStateViewContainer.View.Focus ();
+ }
+ });
+
+ _focusedEventViewContainer.View.Focused += (sender, args) => _focusedEventViewContainer.EventFired ();
+ _unfocusedEventViewContainer.View.Unfocused += (sender, args) => _unfocusedEventViewContainer.EventFired ();
+
+ _gestureRecognizerEventViewContainer.View.GestureRecognizers.Add (
+ new TapGestureRecognizer {
+ Command = new Command (() => _gestureRecognizerEventViewContainer.EventFired ())
+ }
+ );
+
+ _views = new List<View> (viewContainers.Select (o => o.ContainerLayout));
+
+ _moveNextStack = new StackLayout ();
+ var moveNextButton = new Button ();
+ moveNextButton.Text = "Move Next";
+ moveNextButton.AutomationId = "MoveNextButton";
+ moveNextButton.Clicked += delegate (object sender, EventArgs e) {
+ if (!_views.Any ())
+ return;
+
+ if (_currentIndex + 1 >= _views.Count) {
+ return;
+ }
+
+ _currentIndex += 1;
+
+ _moveNextStack.Children.RemoveAt (2);
+ _moveNextStack.Children.Add (_views[_currentIndex]);
+ _picker.SelectedIndexChanged -= PickerSelectedIndexChanged;
+ _picker.SelectedIndex = _currentIndex;
+ _picker.SelectedIndexChanged += PickerSelectedIndexChanged;
+ };
+
+ _picker = new Picker();
+ foreach (var container in viewContainers) {
+ _picker.Items.Add(container.TitleLabel.Text);
+ }
+
+ _picker.SelectedIndex = _currentIndex;
+
+ _picker.SelectedIndexChanged += PickerSelectedIndexChanged;
+
+ _moveNextStack.Children.Add (_picker);
+ _moveNextStack.Children.Add (moveNextButton);
+ _moveNextStack.Children.Add (_views[_currentIndex]);
+
+ stackLayout.Children.Add (_moveNextStack);
+
+ if (!SupportsFocus) {
+ stackLayout.Children.Remove (_focusStateViewContainer.ContainerLayout);
+ stackLayout.Children.Remove (_isFocusedStateViewContainer.ContainerLayout);
+ }
+
+ if (!SupportsTapGestureRecognizer)
+ stackLayout.Children.Remove (_gestureRecognizerEventViewContainer.ContainerLayout);
+
+ foreach (var element in viewContainers)
+ InitializeElement (element.View);
+ }
+
+ void PickerSelectedIndexChanged (object sender, EventArgs eventArgs)
+ {
+ _currentIndex = _picker.SelectedIndex;
+ _moveNextStack.Children.RemoveAt (2);
+ _moveNextStack.Children.Add (_views[_currentIndex]);
+ }
+
+
+ protected virtual bool SupportsTapGestureRecognizer
+ {
+ get { return true; }
+ }
+
+ protected virtual bool SupportsFocus
+ {
+ get { return true; }
+ }
+
+ protected void Add (ViewContainer<T> view) {
+ _views.Add (view.ContainerLayout);
+ _picker.Items.Add(view.TitleLabel.Text);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/DatePickerCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/DatePickerCoreGalleryPage.cs
new file mode 100644
index 00000000..1dbb9bb2
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/DatePickerCoreGalleryPage.cs
@@ -0,0 +1,34 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class DatePickerCoreGalleryPage : CoreGalleryPage<DatePicker>
+ {
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var dateContainer = new ViewContainer<DatePicker> (Test.DatePicker.Date, new DatePicker { Date = new DateTime (1987, 9, 13) });
+
+ var dateSelectedContainer = new EventViewContainer<DatePicker> (Test.DatePicker.DateSelected, new DatePicker ());
+ dateSelectedContainer.View.DateSelected += (sender, args) => dateSelectedContainer.EventFired ();
+
+ var formatDateContainer = new ViewContainer<DatePicker> (Test.DatePicker.Format, new DatePicker { Format = "ddd" });
+ var minimumDateContainer = new ViewContainer<DatePicker> (Test.DatePicker.MinimumDate, new DatePicker { MinimumDate = new DateTime (1987, 9, 13) });
+ var maximumDateContainer = new ViewContainer<DatePicker> (Test.DatePicker.MaximumDate, new DatePicker { MaximumDate = new DateTime (2087, 9, 13) });
+
+ Add (dateContainer);
+ Add (dateSelectedContainer);
+ Add (formatDateContainer);
+ Add (minimumDateContainer);
+ Add (maximumDateContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/EditorCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/EditorCoreGalleryPage.cs
new file mode 100644
index 00000000..d7c749be
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/EditorCoreGalleryPage.cs
@@ -0,0 +1,51 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class EditorCoreGalleryPage : CoreGalleryPage<Editor>
+ {
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var completedContainer = new EventViewContainer<Editor> (Test.Editor.Completed, new Editor ());
+ completedContainer.View.Completed += (sender, args) => completedContainer.EventFired ();
+
+ var textContainer = new ViewContainer<Editor> (Test.Editor.Text, new Editor { Text = "I have text" });
+
+ var textChangedContainer = new EventViewContainer<Editor> (Test.Editor.TextChanged, new Editor ());
+ textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired ();
+
+ var textFontAttributesContainer = new ViewContainer<Editor> (Test.Editor.FontAttributes, new Editor { Text = "I have italic text", FontAttributes = FontAttributes.Italic });
+ var textFamilyContainer1 = new ViewContainer<Editor> (Test.Editor.FontFamily, new Editor { Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS" });
+ var textFamilyContainer2 = new ViewContainer<Editor> (Test.Editor.FontFamily, new Editor { Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold });
+ var textFontSizeContainer = new ViewContainer<Editor> (Test.Editor.FontSize, new Editor { Text = "I have default size text" });
+ var textFontSizeDefaultContainer = new ViewContainer<Editor> (Test.Editor.FontSize, new Editor { Text = "I also have default size text" });
+ textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize (NamedSize.Default, textFontSizeDefaultContainer.View);
+ var textFontSizeLargeContainer = new ViewContainer<Editor> (Test.Editor.FontSize, new Editor { Text = "I have size 48 (huge) text", FontSize = 48 });
+
+ var textColorContainer = new ViewContainer<Editor> (Test.Editor.TextColor,
+ new Editor { Text = "I should have red text", TextColor = Color.Red });
+
+ var textColorDisabledContainer = new ViewContainer<Editor> (Test.Editor.TextColor,
+ new Editor { Text = "I should have the default disabled text color", TextColor = Color.Red, IsEnabled = false });
+
+ Add (completedContainer);
+ Add (textContainer);
+ Add (textChangedContainer);
+ Add (textFontAttributesContainer);
+ Add (textFamilyContainer1);
+ Add (textFamilyContainer2);
+ Add (textFontSizeContainer);
+ Add (textFontSizeDefaultContainer);
+ Add (textFontSizeLargeContainer);
+ Add (textColorContainer);
+ Add (textColorDisabledContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/EntryCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/EntryCoreGalleryPage.cs
new file mode 100644
index 00000000..2180f1f1
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/EntryCoreGalleryPage.cs
@@ -0,0 +1,92 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class EntryCoreGalleryPage : CoreGalleryPage<Entry>
+ {
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var completedContainer = new EventViewContainer<Entry> (Test.Entry.Completed, new Entry { Placeholder = "Completed" });
+ completedContainer.View.Completed += (sender, args) => completedContainer.EventFired ();
+
+ var placeholderContainer = new ViewContainer<Entry> (Test.Entry.Placeholder, new Entry { Placeholder = "Placeholder" });
+ var keyboardContainer = new ViewContainer<Entry> (Test.InputView.Keyboard, new Entry { Keyboard = Keyboard.Numeric });
+ var isPasswordContainer = new ViewContainer<Entry> (Test.Entry.IsPassword, new Entry { IsPassword = true });
+ var textContainer = new ViewContainer<Entry> (Test.Entry.Text, new Entry { Text = "Hi, I am Text" });
+
+ var textChangedContainer = new EventViewContainer<Entry> (Test.Entry.TextChanged, new Entry ());
+ textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired ();
+
+ var textFontAttributesContainer = new ViewContainer<Entry> (Test.Entry.FontAttributes, new Entry { Text = "I have italic text", FontAttributes = FontAttributes.Italic });
+ var textFamilyContainer1 = new ViewContainer<Entry> (Test.Entry.FontFamily, new Entry { Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS" });
+ var textFamilyContainer2 = new ViewContainer<Entry> (Test.Entry.FontFamily, new Entry { Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold });
+ var textFontSizeContainer = new ViewContainer<Entry> (Test.Entry.FontSize, new Entry { Text = "I have default size text" });
+ var textFontSizeDefaultContainer = new ViewContainer<Entry> (Test.Entry.FontSize, new Entry { Text = "I also have default size text" });
+ textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize (NamedSize.Default, textFontSizeDefaultContainer.View);
+ var textFontSizeLargeContainer = new ViewContainer<Entry> (Test.Entry.FontSize, new Entry { Text = "I have size 48 (huge) text", FontSize = 48 });
+
+ var textColorContainer = new ViewContainer<Entry> (Test.Entry.TextColor, new Entry { Text = "Hi, I should be red", TextColor = Color.Red });
+
+ var xAlignCenterContainer = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentCenter,
+ new Entry { Text = "Should be centered", HorizontalTextAlignment = TextAlignment.Center });
+ var xAlignEndContainer = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentEnd,
+ new Entry { Text = "Should be aligned end", HorizontalTextAlignment = TextAlignment.End });
+ var xAlignStartContainer = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentStart,
+ new Entry { Text = "Should be aligned start", HorizontalTextAlignment = TextAlignment.Start });
+
+ var xAlignPlaceholderCenter = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentPlaceholderCenter,
+ new Entry { Placeholder = "Should be centered", HorizontalTextAlignment = TextAlignment.Center });
+ var xAlignPlaceholderEnd = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentPlaceholderEnd,
+ new Entry { Placeholder = "Should be aligned end", HorizontalTextAlignment = TextAlignment.End });
+ var xAlignPlaceholderStart = new ViewContainer<Entry> (Test.Entry.HorizontalTextAlignmentPlaceholderStart,
+ new Entry { Placeholder = "Should be aligned start", HorizontalTextAlignment = TextAlignment.Start });
+
+ var placeholderColorContainer = new ViewContainer<Entry> (Test.Entry.PlaceholderColor,
+ new Entry { Placeholder = "Hi, I should be red", PlaceholderColor = Color.Red });
+
+ var textColorDisabledContainer = new ViewContainer<Entry> (Test.Entry.TextDisabledColor,
+ new Entry { IsEnabled = false, Text = "I should be the default disabled color", TextColor = Color.Red });
+
+ var placeholderColorDisabledContainer = new ViewContainer<Entry> (Test.Entry.PlaceholderDisabledColor,
+ new Entry {
+ IsEnabled = false,
+ Placeholder = "I should be the default placeholder disabled color",
+ PlaceholderColor = Color.Red
+ });
+
+ var passwordColorContainer = new ViewContainer<Entry> (Test.Entry.PasswordColor,
+ new Entry { IsPassword = true, Text = "12345", TextColor = Color.Red });
+
+ Add (isPasswordContainer);
+ Add (completedContainer);
+ Add (placeholderContainer);
+ Add (keyboardContainer);
+ Add (textContainer);
+ Add (textChangedContainer);
+ Add (textColorContainer);
+ Add (xAlignPlaceholderCenter);
+ Add (xAlignCenterContainer);
+ Add (xAlignPlaceholderEnd);
+ Add (xAlignEndContainer);
+ Add (xAlignPlaceholderStart);
+ Add (xAlignStartContainer);
+ Add (textFontAttributesContainer);
+ Add (textFamilyContainer1);
+ Add (textFamilyContainer2);
+ Add (textFontSizeContainer);
+ Add (textFontSizeDefaultContainer);
+ Add (textFontSizeLargeContainer);
+ Add (placeholderColorContainer);
+ Add (textColorDisabledContainer);
+ Add (placeholderColorDisabledContainer);
+ Add (passwordColorContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/FrameCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/FrameCoreGalleryPage.cs
new file mode 100644
index 00000000..aa24172f
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/FrameCoreGalleryPage.cs
@@ -0,0 +1,36 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class FrameCoreGalleryPage : CoreGalleryPage<Frame>
+ {
+ // TODO
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (Frame element)
+ {
+ element.HeightRequest = 50;
+ element.WidthRequest = 100;
+ element.OutlineColor = Color.Olive;
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var hasShadowContainer = new StateViewContainer<Frame> (Test.Frame.HasShadow, new Frame { HasShadow = true });
+ var outlineColorContainer = new StateViewContainer<Frame> (Test.Frame.OutlineColor, new Frame { OutlineColor = Color.Teal, });
+ var viewContainer = new StateViewContainer<Frame> (Test.Frame.OutlineColor, new Frame {
+ OutlineColor = Color.Teal,
+ Content = new Label { Text = "I am a frame" }
+ });
+
+ Add (hasShadowContainer);
+ Add (outlineColorContainer);
+ Add (viewContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/ImageCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/ImageCoreGalleryPage.cs
new file mode 100644
index 00000000..8657e3c0
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/ImageCoreGalleryPage.cs
@@ -0,0 +1,56 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class ImageCoreGalleryPage : CoreGalleryPage<Image>
+ {
+ static readonly Random Rand = new Random ();
+
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (Image element)
+ {
+// var sourceIndex = rand.Next (0, 3);
+//
+// var sources = new [] {
+// ImageSource.FromFile ("oasis.jpg"),
+// //ImageSource.FromUri (new Uri("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg")),
+// //ImageSource.FromResource ("Xamarin.Forms.Controls.ControlGalleryPages.crimson.jpg")
+// };
+
+ //element.Source = sources[sourceIndex];
+ element.Source = "oasissmall.jpg";
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var aspectFillContainer = new ViewContainer<Image> (Test.Image.AspectFill, new Image { Aspect = Aspect.AspectFill });
+ var aspectFitContainer = new ViewContainer<Image> (Test.Image.AspectFit, new Image { Aspect = Aspect.AspectFit });
+ var fillContainer = new ViewContainer<Image> (Test.Image.Fill, new Image { Aspect = Aspect.Fill });
+ var isLoadingContainer = new StateViewContainer<Image> (Test.Image.IsLoading, new Image ());
+ var isOpaqueContainer = new StateViewContainer<Image> (Test.Image.IsOpaque, new Image ());
+
+ InitializeElement (aspectFillContainer.View);
+ InitializeElement (aspectFitContainer.View);
+ InitializeElement (fillContainer.View);
+ InitializeElement (isLoadingContainer.View);
+ InitializeElement (isOpaqueContainer.View);
+
+ var sourceContainer = new ViewContainer<Image> (Test.Image.Source, new Image { Source = "http://sethrosetter.com/images/projects/bezierdraw/bezierdraw_5.jpg" });
+
+ Add (aspectFillContainer);
+ Add (aspectFitContainer);
+ Add (fillContainer);
+ Add (isLoadingContainer);
+ Add (isOpaqueContainer);
+ Add (sourceContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/KeyboardCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/KeyboardCoreGalleryPage.cs
new file mode 100644
index 00000000..cf5f2139
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/KeyboardCoreGalleryPage.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class KeyboardCoreGallery : ContentPage
+ {
+ public KeyboardCoreGallery ()
+ {
+ var keyboardTypes = new[] {
+ Keyboard.Chat,
+ Keyboard.Default,
+ Keyboard.Email,
+ Keyboard.Numeric,
+ Keyboard.Telephone,
+ Keyboard.Text,
+ Keyboard.Url
+ };
+
+ var layout = new StackLayout ();
+
+ foreach (var keyboardType in keyboardTypes) {
+ var viewContainer = new ViewContainer<Entry> (Test.Entry.Keyboard, new Entry { Placeholder = keyboardType.ToString (), Keyboard = keyboardType } );
+ layout.Children.Add (viewContainer.ContainerLayout);
+ }
+
+ var customKeyboards = new [] {
+ Tuple.Create ("Suggestions", Keyboard.Create (KeyboardFlags.Suggestions)),
+ Tuple.Create ("Spellcheck", Keyboard.Create (KeyboardFlags.Spellcheck)),
+ Tuple.Create ("SpellcheckSuggestions", Keyboard.Create (KeyboardFlags.Spellcheck | KeyboardFlags.Suggestions)),
+ Tuple.Create ("Capitalize", Keyboard.Create (KeyboardFlags.CapitalizeSentence)),
+ Tuple.Create ("CapitalizeSuggestions", Keyboard.Create (KeyboardFlags.CapitalizeSentence | KeyboardFlags.Suggestions)),
+ Tuple.Create ("CapitalizeSpellcheck", Keyboard.Create (KeyboardFlags.CapitalizeSentence | KeyboardFlags.Spellcheck)),
+ Tuple.Create ("CapitalizeSpellcheckSuggestions", Keyboard.Create (KeyboardFlags.CapitalizeSentence | KeyboardFlags.Spellcheck | KeyboardFlags.Suggestions)),
+ Tuple.Create ("All", Keyboard.Create (KeyboardFlags.All)),
+ };
+
+ foreach (var customKeyboard in customKeyboards) {
+ var viewContainer = new ViewContainer<Entry> (Test.Entry.Keyboard, new Entry { Placeholder = customKeyboard.Item1, Keyboard = customKeyboard.Item2 } );
+ layout.Children.Add (viewContainer.ContainerLayout);
+ }
+
+ Content = new ScrollView { Content = layout };
+ }
+
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/LabelCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/LabelCoreGalleryPage.cs
new file mode 100644
index 00000000..9043c701
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/LabelCoreGalleryPage.cs
@@ -0,0 +1,158 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class LabelCoreGalleryPage : CoreGalleryPage<Label>
+ {
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (Label element)
+ {
+ element.Text = "I am a label's text.";
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var namedSizeMediumBoldContainer = new ViewContainer<Label> (Test.Label.FontAttibutesBold, new Label { Text = "Medium Bold Font", Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold) });
+ var namedSizeMediumItalicContainer = new ViewContainer<Label> (Test.Label.FontAttributesItalic, new Label { Text = "Medium Italic Font", Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Italic) });
+ var namedSizeLargeContainer = new ViewContainer<Label> (Test.Label.FontNamedSizeLarge, new Label { Text = "Large Font", Font = Font.SystemFontOfSize (NamedSize.Large) });
+ var namedSizeMediumContainer = new ViewContainer<Label> (Test.Label.FontNamedSizeMedium, new Label { Text = "Medium Font", Font = Font.SystemFontOfSize (NamedSize.Medium) });
+ var namedSizeMicroContainer = new ViewContainer<Label> (Test.Label.FontNamedSizeMicro, new Label { Text = "Micro Font", Font = Font.SystemFontOfSize (NamedSize.Micro) });
+ var namedSizeSmallContainer = new ViewContainer<Label> (Test.Label.FontNamedSizeSmall, new Label { Text = "Small Font", Font = Font.SystemFontOfSize (NamedSize.Small) });
+
+ var formattedString = new FormattedString ();
+ formattedString.Spans.Add (new Span { BackgroundColor = Color.Red, ForegroundColor = Color.Olive, Text = "Span 1 " });
+ formattedString.Spans.Add (new Span { BackgroundColor = Color.Black, ForegroundColor = Color.White, Text = "Span 2 " });
+ formattedString.Spans.Add (new Span { BackgroundColor = Color.Pink, ForegroundColor = Color.Purple, Text = "Span 3" });
+
+ var formattedTextContainer = new ViewContainer<Label> (Test.Label.FormattedText, new Label { FormattedText = formattedString });
+
+ const string longText = "Lorem ipsum dolor sit amet, cu mei malis petentium, dolor tempor delicata no qui, eos ex vitae utinam vituperata. Utroque habemus philosophia ut mei, doctus placerat eam cu. An inermis scaevola pro, quo legimus deleniti ei, equidem docendi urbanitas ea eum. Saepe doctus ut pri. Nec ex wisi dolorem. Duo dolor vituperatoribus ea. Id purto instructior per. Nec partem accusamus ne. Qui ad saepe accumsan appellantur, duis omnesque has et, vim nihil nemore scaevola ne. Ei populo appetere recteque cum, meliore splendide appellantur vix id.";
+ var lineBreakModeCharacterWrapContainer = new ViewContainer<Label> (Test.Label.LineBreakModeCharacterWrap, new Label { Text = longText, LineBreakMode = LineBreakMode.CharacterWrap });
+ var lineBreakModeHeadTruncationContainer = new ViewContainer<Label> (Test.Label.LineBreakModeHeadTruncation, new Label { Text = longText, LineBreakMode = LineBreakMode.HeadTruncation });
+ var lineBreakModeMiddleTruncationContainer = new ViewContainer<Label> (Test.Label.LineBreakModeMiddleTruncation, new Label { Text = longText, LineBreakMode = LineBreakMode.MiddleTruncation });
+ var lineBreakModeNoWrapContainer = new ViewContainer<Label> (Test.Label.LineBreakModeNoWrap, new Label { Text = longText, LineBreakMode = LineBreakMode.NoWrap });
+ var lineBreakModeTailTruncationContainer = new ViewContainer<Label> (Test.Label.LineBreakModeTailTruncation, new Label { Text = longText, LineBreakMode = LineBreakMode.TailTruncation });
+ var lineBreakModeWordWrapContainer = new ViewContainer<Label> (Test.Label.LineBreakModeWordWrap, new Label { Text = longText, LineBreakMode = LineBreakMode.WordWrap });
+
+ var textContainer = new ViewContainer<Label> (Test.Label.Text, new Label { Text = "I should have text" });
+ var textColorContainer = new ViewContainer<Label> (Test.Label.TextColor, new Label { Text = "I should have lime text", TextColor = Color.Lime });
+
+ const int alignmentTestsHeightRequest = 100;
+ const int alignmentTestsWidthRequest = 100;
+
+ var xAlignCenterContainer = new ViewContainer<Label> (Test.Label.HorizontalTextAlignmentCenter,
+ new Label {
+ Text = "HorizontalTextAlignment Center",
+ HorizontalTextAlignment = TextAlignment.Center,
+ HeightRequest = alignmentTestsHeightRequest,
+ WidthRequest = alignmentTestsWidthRequest
+ }
+ );
+
+ var xAlignEndContainer = new ViewContainer<Label> (Test.Label.HorizontalTextAlignmentEnd,
+ new Label {
+ Text = "HorizontalTextAlignment End",
+ HorizontalTextAlignment = TextAlignment.End,
+ HeightRequest = alignmentTestsHeightRequest,
+ WidthRequest = alignmentTestsWidthRequest
+ }
+ );
+
+ var xAlignStartContainer = new ViewContainer<Label> (Test.Label.HorizontalTextAlignmentStart,
+ new Label {
+ Text = "HorizontalTextAlignment Start",
+ HorizontalTextAlignment = TextAlignment.Start,
+ HeightRequest = alignmentTestsHeightRequest,
+ WidthRequest = alignmentTestsWidthRequest
+ }
+ );
+
+ var yAlignCenterContainer = new ViewContainer<Label> (Test.Label.VerticalTextAlignmentCenter,
+ new Label {
+ Text = "VerticalTextAlignment Start",
+ VerticalTextAlignment = TextAlignment.Center,
+ HeightRequest = alignmentTestsHeightRequest,
+ WidthRequest = alignmentTestsWidthRequest
+ }
+ );
+
+ var yAlignEndContainer = new ViewContainer<Label> (Test.Label.VerticalTextAlignmentEnd,
+ new Label {
+ Text = "VerticalTextAlignment End",
+ VerticalTextAlignment = TextAlignment.End,
+ HeightRequest = alignmentTestsHeightRequest,
+ WidthRequest = alignmentTestsWidthRequest
+ }
+ );
+
+ var yAlignStartContainer = new ViewContainer<Label> (Test.Label.VerticalTextAlignmentStart,
+ new Label {
+ Text = "VerticalTextAlignment Start",
+ VerticalTextAlignment = TextAlignment.Start,
+ HeightRequest = alignmentTestsHeightRequest,
+ WidthRequest = alignmentTestsWidthRequest
+ }
+ );
+
+ var styleTitleContainer = new ViewContainer<Label> (Test.Device.Styles,
+ new Label {
+ Text = "Device.Styles.TitleStyle",
+ Style = Device.Styles.TitleStyle
+ }
+ );
+
+ var styleSubtitleContainer = new ViewContainer<Label> (Test.Device.Styles,
+ new Label {
+ Text = "Device.Styles.SubtitleStyle",
+ Style = Device.Styles.SubtitleStyle
+ }
+ );
+
+ var styleBodyContainer = new ViewContainer<Label> (Test.Device.Styles,
+ new Label {
+ Text = "Device.Styles.BodyStyle",
+ Style = Device.Styles.BodyStyle
+ }
+ );
+
+ var styleCaptionContainer = new ViewContainer<Label> (Test.Device.Styles,
+ new Label {
+ Text = "Device.Styles.CaptionStyle",
+ Style = Device.Styles.CaptionStyle,
+ }
+ );
+
+ Add (namedSizeMediumBoldContainer);
+ Add (namedSizeMediumItalicContainer);
+ Add (namedSizeLargeContainer);
+ Add (namedSizeMediumContainer);
+ Add (namedSizeMicroContainer);
+ Add (namedSizeSmallContainer);
+ Add (formattedTextContainer);
+ Add (lineBreakModeCharacterWrapContainer);
+ Add (lineBreakModeHeadTruncationContainer);
+ Add (lineBreakModeMiddleTruncationContainer);
+ Add (lineBreakModeNoWrapContainer);
+ Add (lineBreakModeTailTruncationContainer);
+ Add (lineBreakModeWordWrapContainer);
+ Add (textContainer);
+ Add (textColorContainer);
+ Add (xAlignCenterContainer);
+ Add (xAlignEndContainer);
+ Add (xAlignStartContainer);
+ Add (yAlignCenterContainer);
+ Add (yAlignEndContainer);
+ Add (yAlignStartContainer);
+ Add (styleTitleContainer);
+ Add (styleSubtitleContainer);
+ Add (styleBodyContainer);
+ Add (styleCaptionContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/ListViewCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/ListViewCoreGalleryPage.cs
new file mode 100644
index 00000000..ddcd7cef
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/ListViewCoreGalleryPage.cs
@@ -0,0 +1,268 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ internal class ListViewCoreGalleryPage : CoreGalleryPage<ListView>
+ {
+ internal class Employee : INotifyPropertyChanged
+ {
+ string _name;
+ public string Name
+ {
+ get { return _name; }
+ set
+ {
+ if (value != null && value != _name) {
+ _name = value;
+ OnPropertyChanged ();
+ }
+ }
+ }
+
+ TimeSpan _daysWorked;
+ public TimeSpan DaysWorked
+ {
+ get { return _daysWorked; }
+ set
+ {
+ if (value != null && value != _daysWorked) {
+ _daysWorked = value;
+ OnPropertyChanged ();
+ }
+ }
+ }
+
+ int _rowHeight;
+ public int RowHeight
+ {
+ get { return _rowHeight; }
+ set
+ {
+ if (value != null && value != _rowHeight) {
+ _rowHeight = value;
+ OnPropertyChanged ();
+ }
+ }
+ }
+
+ public Employee (string name, TimeSpan daysWorked, int rowHeight)
+ {
+ _name = name;
+ _daysWorked = daysWorked;
+ _rowHeight = rowHeight;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged ([CallerMemberName] string propertyName = null)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ handler (this, new PropertyChangedEventArgs (propertyName));
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class Grouping<K, T> : ObservableCollection<T>
+ {
+ public K Key { get; private set; }
+
+ public Grouping (K key, IEnumerable<T> items)
+ {
+ Key = key;
+ foreach (T item in items) {
+ Items.Add (item);
+ }
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ public class HeaderCell : ViewCell
+ {
+ public HeaderCell ()
+ {
+ Height = 60;
+ var title = new Label {
+ HeightRequest = 60,
+ BackgroundColor = Color.Navy,
+ TextColor = Color.White
+ };
+
+ title.SetBinding (Label.TextProperty, new Binding ("Key"));
+
+ View = new StackLayout {
+ BackgroundColor = Color.Pink,
+ Children = { title }
+ };
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ class UnevenCell : ViewCell
+ {
+ public UnevenCell ()
+ {
+
+ SetBinding (HeightProperty, new Binding("RowHeight"));
+
+ var label = new Label ();
+ label.SetBinding (Label.TextProperty, new Binding("Name"));
+
+ var layout = new StackLayout {
+ BackgroundColor = Color.Red,
+ Children = {
+ label
+ }
+ };
+
+ View = layout;
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ internal class ListViewViewModel
+ {
+ public ObservableCollection<Grouping<string, Employee>> CategorizedEmployees { get; private set; }
+ public ObservableCollection<Employee> Employees { get; private set; }
+
+ public ListViewViewModel ()
+ {
+ CategorizedEmployees = new ObservableCollection<Grouping<string, Employee>> {
+ new Grouping<string, Employee> (
+ "Engineer",
+ new [] {
+ new Employee ("Seth", TimeSpan.FromDays (10), 60),
+ new Employee ("Jason", TimeSpan.FromDays (100), 100),
+ new Employee ("Eric", TimeSpan.FromDays (1000), 160),
+ }
+ ),
+ new Grouping<string, Employee> (
+ "Sales",
+ new [] {
+ new Employee ("Andrew 1", TimeSpan.FromDays (10), 160),
+ new Employee ("Andrew 2", TimeSpan.FromDays (100), 100),
+ new Employee ("Andrew 3", TimeSpan.FromDays (1000), 60),
+ }
+ ),
+ };
+
+ Employees = new ObservableCollection<Employee> {
+ new Employee ("Seth", TimeSpan.FromDays (10), 60),
+ new Employee ("Jason", TimeSpan.FromDays (100), 100),
+ new Employee ("Eric", TimeSpan.FromDays (1000), 160),
+ new Employee ("Andrew 1", TimeSpan.FromDays (10), 160),
+ new Employee ("Andrew 2", TimeSpan.FromDays (100), 100),
+ new Employee ("Andrew 3", TimeSpan.FromDays (1000), 60),
+ };
+
+ Enumerable.Range (0, 9000).Select (e => new Employee (e.ToString (), TimeSpan.FromDays (1), 60)).ForEach (e => Employees.Add (e));
+ }
+ }
+
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (ListView element)
+ {
+ element.HeightRequest = 350;
+ element.RowHeight = 60;
+
+ var viewModel = new ListViewViewModel ();
+ element.BindingContext = viewModel;
+
+ element.ItemsSource = viewModel.Employees;
+
+ var template = new DataTemplate (typeof(TextCell));
+ template.SetBinding (TextCell.TextProperty, "Name");
+ template.SetBinding (TextCell.DetailProperty, new Binding("DaysWorked", converter: new GenericValueConverter (time => time.ToString ())));
+
+ element.ItemTemplate = template;
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var viewModel = new ListViewViewModel ();
+
+ var groupDisplayBindingContainer = new ViewContainer<ListView> (Test.ListView.GroupDisplayBinding, new ListView ());
+ InitializeElement (groupDisplayBindingContainer.View);
+ groupDisplayBindingContainer.View.ItemsSource = viewModel.CategorizedEmployees;
+ groupDisplayBindingContainer.View.IsGroupingEnabled = true;
+ groupDisplayBindingContainer.View.GroupDisplayBinding = new Binding ("Key");
+
+
+ var groupHeaderTemplateContainer = new ViewContainer<ListView> (Test.ListView.GroupHeaderTemplate, new ListView ());
+ InitializeElement (groupHeaderTemplateContainer.View);
+ groupHeaderTemplateContainer.View.ItemsSource = viewModel.CategorizedEmployees;
+ groupHeaderTemplateContainer.View.IsGroupingEnabled = true;
+ groupHeaderTemplateContainer.View.GroupHeaderTemplate = new DataTemplate (typeof (HeaderCell));
+
+ var groupShortNameContainer = new ViewContainer<ListView> (Test.ListView.GroupShortNameBinding, new ListView ());
+ InitializeElement (groupShortNameContainer.View);
+ groupShortNameContainer.View.ItemsSource = viewModel.CategorizedEmployees;
+ groupShortNameContainer.View.IsGroupingEnabled = true;
+ groupShortNameContainer.View.GroupShortNameBinding = new Binding("Key");
+
+ // TODO - not sure how to do this
+ var hasUnevenRowsContainer = new ViewContainer<ListView> (Test.ListView.HasUnevenRows, new ListView ());
+ InitializeElement (hasUnevenRowsContainer.View);
+ hasUnevenRowsContainer.View.HasUnevenRows = true;
+ hasUnevenRowsContainer.View.ItemTemplate = new DataTemplate (typeof(UnevenCell));
+
+ var isGroupingEnabledContainer = new StateViewContainer<ListView> (Test.ListView.IsGroupingEnabled, new ListView ());
+ InitializeElement (isGroupingEnabledContainer.View);
+ isGroupingEnabledContainer.View.ItemsSource = viewModel.CategorizedEmployees;
+ isGroupingEnabledContainer.View.IsGroupingEnabled = true;
+ isGroupingEnabledContainer.StateChangeButton.Clicked += (sender, args) => isGroupingEnabledContainer.View.IsGroupingEnabled = !isGroupingEnabledContainer.View.IsGroupingEnabled;
+
+
+ var itemAppearingContainer = new EventViewContainer<ListView> (Test.ListView.ItemAppearing, new ListView ());
+ InitializeElement (itemAppearingContainer.View);
+ itemAppearingContainer.View.ItemAppearing += (sender, args) => itemAppearingContainer.EventFired ();
+
+ var itemDisappearingContainer = new EventViewContainer<ListView> (Test.ListView.ItemDisappearing, new ListView ());
+ InitializeElement (itemDisappearingContainer.View);
+ itemDisappearingContainer.View.ItemDisappearing += (sender, args) => itemDisappearingContainer.EventFired ();
+
+ var itemSelectedContainer = new EventViewContainer<ListView> (Test.ListView.ItemSelected, new ListView ());
+ InitializeElement (itemSelectedContainer.View);
+ itemSelectedContainer.View.ItemSelected += (sender, args) => itemSelectedContainer.EventFired ();
+
+ var itemTappedContainer = new EventViewContainer<ListView> (Test.ListView.ItemTapped, new ListView ());
+ InitializeElement (itemTappedContainer.View);
+ itemTappedContainer.View.ItemTapped += (sender, args) => itemTappedContainer.EventFired ();
+
+ // TODO
+ var rowHeightContainer = new ViewContainer<ListView> (Test.ListView.RowHeight, new ListView ());
+ InitializeElement (rowHeightContainer.View);
+
+ var selectedItemContainer = new ViewContainer<ListView> (Test.ListView.SelectedItem, new ListView ());
+ InitializeElement (selectedItemContainer.View);
+ selectedItemContainer.View.SelectedItem = viewModel.Employees[2];
+
+ Add (groupDisplayBindingContainer);
+ Add (groupHeaderTemplateContainer);
+ Add (groupShortNameContainer);
+ Add (hasUnevenRowsContainer);
+ Add (isGroupingEnabledContainer);
+ Add (itemAppearingContainer);
+ Add (itemDisappearingContainer);
+ Add (itemSelectedContainer);
+ Add (itemTappedContainer);
+ Add (rowHeightContainer);
+ Add (selectedItemContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/OpenGLViewCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/OpenGLViewCoreGalleryPage.cs
new file mode 100644
index 00000000..d057ca9d
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/OpenGLViewCoreGalleryPage.cs
@@ -0,0 +1,16 @@
+namespace Xamarin.Forms.Controls
+{
+ internal class OpenGLViewCoreGalleryPage : CoreGalleryPage<OpenGLView>
+ {
+ // TODO
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/PickerCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/PickerCoreGalleryPage.cs
new file mode 100644
index 00000000..cea755d4
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/PickerCoreGalleryPage.cs
@@ -0,0 +1,35 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class PickerCoreGalleryPage : CoreGalleryPage<Picker>
+ {
+ // TODO
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ var itemsContainer = new ViewContainer<Picker> (Test.Picker.Items, new Picker ());
+ itemsContainer.View.Items.Add ("Item 1");
+ itemsContainer.View.Items.Add ("Item 2");
+ itemsContainer.View.Items.Add ("Item 3");
+
+ var selectedIndexContainer = new ViewContainer<Picker> (Test.Picker.SelectedIndex, new Picker ());
+ selectedIndexContainer.View.Items.Add ("Item 1");
+ selectedIndexContainer.View.Items.Add ("Item 2");
+ selectedIndexContainer.View.Items.Add ("Item 3");
+ selectedIndexContainer.View.SelectedIndex = 2;
+
+ var titleContainer = new ViewContainer<Picker> (Test.Picker.Title, new Picker ());
+ titleContainer.View.Title = "Title";
+
+ Add (itemsContainer);
+ Add (selectedIndexContainer);
+ Add (titleContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/ProgressBarCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/ProgressBarCoreGalleryPage.cs
new file mode 100644
index 00000000..1cc51ae8
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/ProgressBarCoreGalleryPage.cs
@@ -0,0 +1,27 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class ProgressBarCoreGalleryPage : CoreGalleryPage<ProgressBar>
+ {
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (ProgressBar element)
+ {
+ base.InitializeElement (element);
+
+ element.Progress = 1;
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var progressContainer = new ViewContainer<ProgressBar> (Test.ProgressBar.Progress, new ProgressBar { Progress = 0.5 });
+ Add (progressContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/SearchBarCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/SearchBarCoreGalleryPage.cs
new file mode 100644
index 00000000..0221b87c
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/SearchBarCoreGalleryPage.cs
@@ -0,0 +1,89 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class SearchBarCoreGalleryPage : CoreGalleryPage<SearchBar>
+ {
+ // TODO
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ var placeholderContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceHolder, new SearchBar { Placeholder = "Placeholder" });
+
+ var searchButtonPressedContainer = new EventViewContainer<SearchBar> (Test.SearchBar.SearchButtonPressed, new SearchBar { });
+ searchButtonPressedContainer.View.SearchButtonPressed += (sender, args) => searchButtonPressedContainer.EventFired ();
+
+ var searchCommandContainer = new ViewContainer<SearchBar> (Test.SearchBar.SearchCommand,
+ new SearchBar {
+ SearchCommand = new Command (async () => await DisplayAlert ("Search command", "Fired", "Ok"))
+ }
+ );
+
+ var textContainer = new ViewContainer<SearchBar> (Test.SearchBar.Text, new SearchBar { Text = "I am text" });
+
+ var textChangedContainer = new EventViewContainer<SearchBar> (Test.SearchBar.TextChanged, new SearchBar { Placeholder = "I am text changed" });
+ textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired ();
+
+ var cancelButtonColor = new ViewContainer<SearchBar> (
+ Test.SearchBar.CancelButtonColor,
+ new SearchBar {
+ Placeholder = "Should have a red cancel button",
+ CancelButtonColor = Color.Red
+ }
+ );
+
+ var textFontAttributesContainer = new ViewContainer<SearchBar> (Test.SearchBar.FontAttributes, new SearchBar { Text = "I have italic text", FontAttributes = FontAttributes.Italic });
+ var textFamilyContainer1 = new ViewContainer<SearchBar> (Test.SearchBar.FontFamily, new SearchBar { Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS" });
+ var textFamilyContainer2 = new ViewContainer<SearchBar> (Test.SearchBar.FontFamily, new SearchBar { Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold });
+ var textFontSizeContainer = new ViewContainer<SearchBar> (Test.SearchBar.FontSize, new SearchBar { Text = "I have default size text" });
+ var textFontSizeDefaultContainer = new ViewContainer<SearchBar> (Test.SearchBar.FontSize, new SearchBar { Text = "I also have default size text" });
+ textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize (NamedSize.Default, textFontSizeDefaultContainer.View);
+ var textFontSizeLargeContainer = new ViewContainer<SearchBar> (Test.SearchBar.FontSize, new SearchBar { Text = "I have size 48 (huge) text", FontSize = 48 });
+
+ var textAlignmentStartContainer = new ViewContainer<SearchBar> (Test.SearchBar.TextAlignmentStart,
+ new SearchBar { Text = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start });
+ var textAlignmentCenterContainer = new ViewContainer<SearchBar> (Test.SearchBar.TextAlignmentCenter,
+ new SearchBar { Text = "I should be centered", HorizontalTextAlignment = TextAlignment.Center });
+ var textAlignmentEndContainer = new ViewContainer<SearchBar> (Test.SearchBar.TextAlignmentEnd,
+ new SearchBar { Text = "I should be at the end", HorizontalTextAlignment = TextAlignment.End });
+
+ var placeholderAlignmentStartContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderAlignmentStart,
+ new SearchBar { Placeholder = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start });
+ var placeholderAlignmentCenterContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderAlignmentCenter,
+ new SearchBar { Placeholder = "I should be centered", HorizontalTextAlignment = TextAlignment.Center });
+ var placeholderAlignmentEndContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderAlignmentEnd,
+ new SearchBar { Placeholder = "I should be at the end", HorizontalTextAlignment = TextAlignment.End });
+
+ var textColorContainer = new ViewContainer<SearchBar> (Test.SearchBar.TextColor,
+ new SearchBar { Text = "I should be red", TextColor = Color.Red });
+
+ var placeholderColorContainer = new ViewContainer<SearchBar> (Test.SearchBar.PlaceholderColor,
+ new SearchBar { Placeholder = "I should be red", PlaceholderColor = Color.Red });
+ Add (placeholderContainer);
+ Add (searchButtonPressedContainer);
+ Add (searchCommandContainer);
+ Add (textContainer);
+ Add (textChangedContainer);
+ Add (textFontAttributesContainer);
+ Add (textFamilyContainer1);
+ Add (textFamilyContainer2);
+ Add (textFontSizeContainer);
+ Add (textFontSizeDefaultContainer);
+ Add (textFontSizeLargeContainer);
+ Add (cancelButtonColor);
+ Add (textAlignmentStartContainer);
+ Add (textAlignmentCenterContainer);
+ Add (textAlignmentEndContainer);
+ Add (placeholderAlignmentStartContainer);
+ Add (placeholderAlignmentCenterContainer);
+ Add (placeholderAlignmentEndContainer);
+ Add (textColorContainer);
+ Add (placeholderColorContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/SliderCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/SliderCoreGalleryPage.cs
new file mode 100644
index 00000000..be813110
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/SliderCoreGalleryPage.cs
@@ -0,0 +1,29 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class SliderCoreGalleryPage : CoreGalleryPage<Slider>
+ {
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ var maximumContainer = new ValueViewContainer<Slider> (Test.Slider.Maximum, new Slider { Maximum = 10, Minimum = 5 }, "Value", value => value.ToString ());
+ var minimumContainer = new ValueViewContainer<Slider> (Test.Slider.Minimum, new Slider { Maximum = 10 }, "Value", value => value.ToString ());
+ var valueContainer = new ValueViewContainer<Slider> (Test.Slider.Value, new Slider { Value = 0.5 }, "Value", value => value.ToString ());
+
+ Add (maximumContainer);
+ Add (minimumContainer);
+ Add (valueContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/StepperCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/StepperCoreGalleryPage.cs
new file mode 100644
index 00000000..2ff15466
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/StepperCoreGalleryPage.cs
@@ -0,0 +1,29 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class StepperCoreGalleryPage : CoreGalleryPage<Stepper>
+ {
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ var maximumContainer = new ValueViewContainer<Stepper> (Test.Stepper.Maximum, new Stepper { Maximum = 10 }, "Value", value => value.ToString ());
+ var minimumContainer = new ValueViewContainer<Stepper> (Test.Stepper.Minimum, new Stepper { Minimum = 2 }, "Value", value => value.ToString ());
+ var incrememtContainer = new ValueViewContainer<Stepper> (Test.Stepper.Increment, new Stepper { Maximum = 20, Minimum = 10, Increment = 2 }, "Value", value => value.ToString ());
+
+ Add (maximumContainer);
+ Add (minimumContainer);
+ Add (incrememtContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/SwitchCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/SwitchCoreGalleryPage.cs
new file mode 100644
index 00000000..5d9ebcfb
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/SwitchCoreGalleryPage.cs
@@ -0,0 +1,25 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class SwitchCoreGalleryPage : CoreGalleryPage<Switch>
+ {
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var isToggledContainer = new ValueViewContainer<Switch> (Test.Switch.IsToggled, new Switch (), "IsToggled", value => value.ToString ());
+ Add (isToggledContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/TableViewCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/TableViewCoreGalleryPage.cs
new file mode 100644
index 00000000..f5c7a077
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/TableViewCoreGalleryPage.cs
@@ -0,0 +1,16 @@
+namespace Xamarin.Forms.Controls
+{
+ internal class TableViewCoreGalleryPage : CoreGalleryPage<TableView>
+ {
+ // TODO
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/TimePickerCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/TimePickerCoreGalleryPage.cs
new file mode 100644
index 00000000..bf8b9c98
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/TimePickerCoreGalleryPage.cs
@@ -0,0 +1,24 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class TimePickerCoreGalleryPage : CoreGalleryPage<TimePicker>
+ {
+ protected override bool SupportsTapGestureRecognizer
+ {
+ get { return false; }
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+ var formatContainer = new ViewContainer<TimePicker> (Test.TimePicker.Format, new TimePicker { Format = "HH-mm-ss" });
+ var timeContainer = new ViewContainer<TimePicker> (Test.TimePicker.Time, new TimePicker { Time = new TimeSpan (14, 45, 50) });
+
+ Add (formatContainer);
+ Add (timeContainer);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/CoreGalleryPages/WebViewCoreGalleryPage.cs b/Xamarin.Forms.Controls/CoreGalleryPages/WebViewCoreGalleryPage.cs
new file mode 100644
index 00000000..229aed3b
--- /dev/null
+++ b/Xamarin.Forms.Controls/CoreGalleryPages/WebViewCoreGalleryPage.cs
@@ -0,0 +1,62 @@
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ internal class WebViewCoreGalleryPage : CoreGalleryPage<WebView>
+ {
+ protected override bool SupportsFocus
+ {
+ get { return false; }
+ }
+
+ protected override void InitializeElement (WebView element)
+ {
+ element.HeightRequest = 200;
+
+ element.Source = new UrlWebViewSource { Url = "http://xamarin.com/" };
+ }
+
+ protected override void Build (StackLayout stackLayout)
+ {
+ base.Build (stackLayout);
+
+ var urlWebViewSourceContainer = new ViewContainer<WebView> (Test.WebView.UrlWebViewSource,
+ new WebView {
+ Source = new UrlWebViewSource { Url = "https://www.google.com/" },
+ HeightRequest = 200
+ }
+ );
+
+ const string html = "<html><div class=\"test\"><h2>I am raw html</h2></div></html>";
+ var htmlWebViewSourceContainer = new ViewContainer<WebView> (Test.WebView.HtmlWebViewSource,
+ new WebView {
+ Source = new HtmlWebViewSource { Html = html },
+ HeightRequest = 200
+ }
+ );
+
+ var htmlFileWebSourceContainer = new ViewContainer<WebView> (Test.WebView.LoadHtml,
+ new WebView {
+ Source = new HtmlWebViewSource {
+ Html = @"<html>
+<head>
+<link rel=""stylesheet"" href=""default.css"">
+</head>
+<body>
+<h1>Xamarin.Forms</h1>
+<p>The CSS and image are loaded from local files!</p>
+<img src='WebImages/XamarinLogo.png'/>
+<p><a href=""local.html"">next page</a></p>
+</body>
+</html>"
+ },
+ HeightRequest = 200
+ }
+ );
+
+ Add (urlWebViewSourceContainer);
+ Add (htmlWebViewSourceContainer);
+ Add (htmlFileWebSourceContainer);
+ }
+ }
+} \ No newline at end of file