public HomePage()
        {
            InitializeComponent();

#if __IOS__
            const string originalText = "Native UILabel.";
            const string longerText   = "Native UILabel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var uiLabel = new UILabel {
                MinimumFontSize = 14f,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = originalText,
            };
            stackLayout.Children.Add(uiLabel);

            var uiButton = new UIButton(UIButtonType.RoundedRect);
            uiButton.SetTitle("Change Text", UIControlState.Normal);
            uiButton.Font           = UIFont.FromName("Helvetica", 14f);
            uiButton.TouchUpInside += (sender, args) => {
                uiLabel.Text = uiLabel.Text == originalText ? longerText : originalText;
                uiLabel.SizeToFit();
            };
            stackLayout.Children.Add(uiButton);

            var explanation1 = new UILabel {
                MinimumFontSize = 14f,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "The next control is a CustomControl (a customized UILabel with a bad SizeThatFits implementation).",
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl {
                MinimumFontSize = 14,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "This control has incorrect sizing - there's empty space above and below it."
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new UILabel {
                MinimumFontSize = 14f,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "The next control is a CustomControl, but an override to the GetDesiredSize method is passed in when adding the control to the layout.",
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl {
                MinimumFontSize = 14,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "This control has correct sizing - there's no empty space above and below it."
            };
            stackLayout.Children.Add(fixedControl, FixSize);
#endif

#if __ANDROID__
            const string originalText = "Native TextView.";
            const string longerText   = "Native TextView. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textView = new TextView(MainActivity.Instance)
            {
                Text = originalText, TextSize = 14
            };
            textView.SetSingleLine(false);
            textView.SetLines(3);
            stackLayout.Children.Add(textView);

            var button = new Android.Widget.Button(MainActivity.Instance)
            {
                Text = "Change Text"
            };
            button.Click += (sender, args) =>
            {
                textView.Text = textView.Text == originalText ? longerText : originalText;
            };
            stackLayout.Children.Add(button);

            var explanation1 = new TextView(MainActivity.Instance)
            {
                Text     = "The next control is a CustomControl (a customized TextView with a bad OnMeasure implementation).",
                TextSize = 14
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl(MainActivity.Instance)
            {
                Text     = "This control has incorrect sizing - it doesn't occupy the available width of the device.",
                TextSize = 14
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextView(MainActivity.Instance)
            {
                Text     = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.",
                TextSize = 14
            };
            stackLayout.Children.Add(explanation2);

            var goodControl = new CustomControl(MainActivity.Instance)
            {
                Text     = "This control has correct sizing - it occupies the available width of the device.",
                TextSize = 14
            };
            stackLayout.Children.Add(goodControl, FixSize);
#endif

#if WINDOWS_PHONE_APP
            const string originalText = "Native TextBlock.";
            const string longerText   = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textBlock = new TextBlock
            {
                Text         = originalText,
                FontSize     = 14,
                FontFamily   = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(textBlock);

            var button = new Windows.UI.Xaml.Controls.Button {
                Content = "Change Text"
            };
            button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; };
            stackLayout.Children.Add(button);

            var explanation1 = new TextBlock
            {
                Text         = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).",
                FontSize     = 14,
                FontFamily   = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl {
                Text = "This control has incorrect sizing - it doesn't occupy the available width of the device."
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextBlock
            {
                Text         = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.",
                FontSize     = 14,
                FontFamily   = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl {
                Text = "This control has correct sizing - it occupies the available width of the device."
            };
            stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) =>
            {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return(null);
                }
                var frameworkElement = renderer.Control;
                frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height));
                return(finalSize);
            });
#endif

#if WINDOWS_UWP
            const string originalText = "Native TextBlock.";
            const string longerText   = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textBlock = new TextBlock
            {
                Text         = originalText,
                FontSize     = 14,
                FontFamily   = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(textBlock);

            var button = new Windows.UI.Xaml.Controls.Button {
                Content = "Change Text"
            };
            button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; };
            stackLayout.Children.Add(button);

            var explanation1 = new TextBlock
            {
                Text         = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).",
                FontSize     = 14,
                FontFamily   = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl {
                Text = "This control has incorrect sizing - it doesn't occupy the available width of the device."
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextBlock
            {
                Text         = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.",
                FontSize     = 14,
                FontFamily   = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl {
                Text = "This control has correct sizing - it occupies the available width of the device."
            };
            stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) =>
            {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return(null);
                }
                var frameworkElement = renderer.Control;
                frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height));
                return(finalSize);
            });
#endif
        }
		public HomePage ()
		{
			InitializeComponent ();

#if __IOS__
			const string originalText = "Native UILabel.";
			const string longerText = "Native UILabel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

			var uiLabel = new UILabel {
				MinimumFontSize = 14f,
				Lines = 0,
				LineBreakMode = UILineBreakMode.WordWrap,
				Text = originalText,
			};
			stackLayout.Children.Add (uiLabel);

			var uiButton = new UIButton (UIButtonType.RoundedRect);
			uiButton.SetTitle ("Change Text", UIControlState.Normal);
			uiButton.Font = UIFont.FromName ("Helvetica", 14f);
			uiButton.TouchUpInside += (sender, args) => {
				uiLabel.Text = uiLabel.Text == originalText ? longerText : originalText;
				uiLabel.SizeToFit ();
			};
			stackLayout.Children.Add (uiButton);

			var explanation1 = new UILabel {
				MinimumFontSize = 14f,
				Lines = 0,
				LineBreakMode = UILineBreakMode.WordWrap,
				Text = "The next control is a CustomControl (a customized UILabel with a bad SizeThatFits implementation).",
			};
			stackLayout.Children.Add (explanation1);

			var brokenControl = new CustomControl {
				MinimumFontSize = 14,
				Lines = 0,
				LineBreakMode = UILineBreakMode.WordWrap,
				Text = "This control has incorrect sizing - there's empty space above and below it."
			};
			stackLayout.Children.Add (brokenControl);

			var explanation2 = new UILabel {
				MinimumFontSize = 14f,
				Lines = 0,
				LineBreakMode = UILineBreakMode.WordWrap,
				Text = "The next control is a CustomControl, but an override to the GetDesiredSize method is passed in when adding the control to the layout.",
			};
			stackLayout.Children.Add (explanation2);

			var fixedControl = new CustomControl {
				MinimumFontSize = 14,
				Lines = 0,
				LineBreakMode = UILineBreakMode.WordWrap,
				Text = "This control has correct sizing - there's no empty space above and below it."
			};
			stackLayout.Children.Add (fixedControl, FixSize);
#endif

#if __ANDROID__
			const string originalText = "Native TextView.";
			const string longerText = "Native TextView. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

			var textView = new TextView (Forms.Context) { Text = originalText, TextSize = 14 };
			textView.SetSingleLine (false);
			textView.SetLines (3);
			stackLayout.Children.Add (textView);

			var button = new Android.Widget.Button (Forms.Context) { Text = "Change Text" };
			button.Click += (sender, args) => {
				textView.Text = textView.Text == originalText ? longerText : originalText;
			};
			stackLayout.Children.Add (button);

			var explanation1 = new TextView (Forms.Context) {
				Text = "The next control is a CustomControl (a customized TextView with a bad OnMeasure implementation).",
				TextSize = 14
			};
			stackLayout.Children.Add (explanation1);

			var brokenControl = new CustomControl (Forms.Context) {
				Text = "This control has incorrect sizing - it doesn't occupy the available width of the device.",
				TextSize = 14
			};
			stackLayout.Children.Add (brokenControl);

			var explanation2 = new TextView (Forms.Context) {
				Text = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.",
				TextSize = 14
			};
			stackLayout.Children.Add (explanation2);

			var goodControl = new CustomControl (Forms.Context) {
				Text = "This control has correct sizing - it occupies the available width of the device.",
				TextSize = 14
			};
			stackLayout.Children.Add (goodControl, FixSize);
#endif

#if WINDOWS_PHONE_APP
            const string originalText = "Native TextBlock.";
            const string longerText = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textBlock = new TextBlock
            {
                Text = originalText,
                FontSize = 14,
                FontFamily = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(textBlock);

            var button = new Windows.UI.Xaml.Controls.Button { Content = "Change Text" };
            button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; };
            stackLayout.Children.Add(button);

            var explanation1 = new TextBlock
            {
                Text = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).",
                FontSize = 14,
                FontFamily = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl { Text = "This control has incorrect sizing - it doesn't occupy the available width of the device." };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextBlock
            {
                Text = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.",
                FontSize = 14,
                FontFamily = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl { Text = "This control has correct sizing - it occupies the available width of the device." };
            stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) =>
            {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return null;
                }
                var frameworkElement = renderer.Control;
                frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height));
                return finalSize;
            }); 
#endif

#if WINDOWS_UWP
            const string originalText = "Native TextBlock.";
            const string longerText = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textBlock = new TextBlock
            {
                Text = originalText,
                FontSize = 14,
                FontFamily = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(textBlock);

            var button = new Windows.UI.Xaml.Controls.Button { Content = "Change Text" };
            button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; };
            stackLayout.Children.Add(button);

            var explanation1 = new TextBlock
            {
                Text = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).",
                FontSize = 14,
                FontFamily = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl { Text = "This control has incorrect sizing - it doesn't occupy the available width of the device." };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextBlock
            {
                Text = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.",
                FontSize = 14,
                FontFamily = new FontFamily("HelveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl { Text = "This control has correct sizing - it occupies the available width of the device." };
            stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) =>
            {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return null;
                }
                var frameworkElement = renderer.Control;
                frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height));
                return finalSize;
            });
#endif
		}
Example #3
0
        public HomePageCS()
        {
            var stackLayout = new StackLayout {
                Children =
                {
                    new Label {
                        Text              = "Nest Platform Control Demo",
                        FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        FontAttributes    = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    new Label {
                        Text = "The controls below the separator have been added to this Xamarin.Forms page using platform-specific controls."
                    },
                    new Separator()
                }
            };

            Content = new Xamarin.Forms.ScrollView {
                Margin  = new Xamarin.Forms.Thickness(20, 40, 20, 0),
                Content = stackLayout
            };

                        #if __IOS__
            const string originalText = "Native UILabel.";
            const string longerText   = "Native UILabel. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var uiLabel = new UILabel {
                MinimumFontSize = 14f,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = originalText,
            };
            stackLayout.Children.Add(uiLabel);

            var uiButton = new UIButton(UIButtonType.RoundedRect);
            uiButton.SetTitle("Change Text", UIControlState.Normal);
            uiButton.Font           = UIFont.FromName("Helvetica", 14f);
            uiButton.TouchUpInside += (sender, args) => {
                uiLabel.Text = uiLabel.Text == originalText ? longerText : originalText;
                uiLabel.SizeToFit();
            };
            stackLayout.Children.Add(uiButton);

            var explanation1 = new UILabel {
                MinimumFontSize = 14f,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "The next control is a CustomControl (a customized UILabel with a bad SizeThatFits implementation).",
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl {
                MinimumFontSize = 14,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "This control has incorrect sizing - there's empty space above and below it."
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new UILabel {
                MinimumFontSize = 14f,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "The next control is a CustomControl, but an override to the GetDesiredSize method is passed in when adding the control to the layout.",
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl {
                MinimumFontSize = 14,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "This control has correct sizing - there's no empty space above and below it."
            };
            stackLayout.Children.Add(fixedControl, FixSize);
                        #endif

                        #if __ANDROID__
            const string originalText = "Native TextView.";
            const string longerText   = "Native TextView. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textView = new TextView(Forms.Context)
            {
                Text = originalText, TextSize = 14
            };
            textView.SetSingleLine(false);
            textView.SetLines(3);
            stackLayout.Children.Add(textView);

            var button = new Android.Widget.Button(Forms.Context)
            {
                Text = "Change Text"
            };
            button.Click += (sender, args) => {
                textView.Text = textView.Text == originalText ? longerText : originalText;
            };
            stackLayout.Children.Add(button);

            var explanation1 = new TextView(Forms.Context)
            {
                Text     = "The next control is a CustomControl (a customized TextView with a bad OnMeasure implementation).",
                TextSize = 14
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl(Forms.Context)
            {
                Text     = "This control has incorrect sizing - it doesn't occupy the available width of the device.",
                TextSize = 14
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextView(Forms.Context)
            {
                Text     = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.",
                TextSize = 14
            };
            stackLayout.Children.Add(explanation2);

            var goodControl = new CustomControl(Forms.Context)
            {
                Text     = "This control has correct sizing - it occupies the available width of the device.",
                TextSize = 14
            };
            stackLayout.Children.Add(goodControl, FixSize);
                        #endif

                        #if WINDOWS_PHONE_APP
            const string originalText = "Native TextBlock.";
            const string longerText   = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textBlock = new TextBlock
            {
                Text         = originalText,
                FontSize     = 14,
                FontFamily   = new FontFamily("HeveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(textBlock);

            var button = new Windows.UI.Xaml.Controls.Button {
                Content = "Change Text"
            };
            button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; };
            stackLayout.Children.Add(button);

            var explanation1 = new TextBlock
            {
                Text         = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).",
                FontSize     = 14,
                FontFamily   = new FontFamily("HeveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl {
                Text = "This control has incorrect sizing - it doesn't occupy the available width of the device."
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextBlock
            {
                Text         = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.",
                FontSize     = 14,
                FontFamily   = new FontFamily("HeveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl {
                Text = "This control has correct sizing - it occupies the available width of the device."
            };
            stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) =>
            {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return(null);
                }
                var frameworkElement = renderer.Control;
                frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height));
                return(finalSize);
            });
                        #endif

                        #if WINDOWS_UWP
            const string originalText = "Native TextBlock.";
            const string longerText   = "Native TextBlock. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var textBlock = new TextBlock
            {
                Text         = originalText,
                FontSize     = 14,
                FontFamily   = new FontFamily("HeveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(textBlock);

            var button = new Windows.UI.Xaml.Controls.Button {
                Content = "Change Text"
            };
            button.Click += (sender, args) => { textBlock.Text = textBlock.Text == originalText ? longerText : originalText; };
            stackLayout.Children.Add(button);

            var explanation1 = new TextBlock
            {
                Text         = "The next control is a CustomControl (a customized TextBlock with a bad ArrangeOverride implementation).",
                FontSize     = 14,
                FontFamily   = new FontFamily("HeveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation1);

            var brokenControl = new CustomControl {
                Text = "This control has incorrect sizing - it doesn't occupy the available width of the device."
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new TextBlock
            {
                Text         = "The next control is a CustomControl, but an ArrangeOverride delegate is passed in when adding the control to the layout.",
                FontSize     = 14,
                FontFamily   = new FontFamily("HeveticaNeue"),
                TextWrapping = TextWrapping.Wrap
            };
            stackLayout.Children.Add(explanation2);

            var fixedControl = new CustomControl {
                Text = "This control has correct sizing - it occupies the available width of the device."
            };
            stackLayout.Children.Add(fixedControl, arrangeOverrideDelegate: (renderer, finalSize) =>
            {
                if (finalSize.Width <= 0 || double.IsInfinity(finalSize.Width))
                {
                    return(null);
                }
                var frameworkElement = renderer.Control;
                frameworkElement.Arrange(new Rect(0, 0, finalSize.Width * 2, finalSize.Height));
                return(finalSize);
            });
#endif

                        #if __TIZEN__
            const string originalText = "Native ElmSharp.Label.";
            const string longerText   = "Native ElmSharp.Label. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel elit orci. Nam sollicitudin consectetur congue.";

            var label = new ElmSharp.Label(Tizen.Program.ElmWindow)
            {
                Text = originalText,
                // Line Wrap does not applied to longerText as expected because ElmSharp.Label does not measure itself.
                LineWrapType = ElmSharp.WrapType.Char
            };
            stackLayout.Children.Add(label);

            var button = new ElmSharp.Button(Tizen.Program.ElmWindow)
            {
                Text = "Change Text"
            };
            button.Clicked += (sender, args) =>
            {
                label.Text = label.Text == originalText ? longerText : originalText;
            };
            stackLayout.Children.Add(button);

            var explanation1 = new ElmSharp.Label(Tizen.Program.ElmWindow)
            {
                Text         = "The next control is a CustomControl (a customized ElmSharp.Label without any measurement method).",
                LineWrapType = ElmSharp.WrapType.Char,
            };
            // measureDelegate is required to show the line wrap option properly.
            stackLayout.Children.Add(explanation1, FixSize);

            var brokenControl = new CustomControl(Tizen.Program.ElmWindow)
            {
                Text     = "This control has incorrect sizing - there's empty space above and below it.",
                FontSize = 28
            };
            stackLayout.Children.Add(brokenControl);

            var explanation2 = new ElmSharp.Label(Tizen.Program.ElmWindow)
            {
                Text         = "The next control is a CustomControl, but with a custom GetDesiredSize delegate to accomodate it's sizing problem.",
                LineWrapType = ElmSharp.WrapType.Word,
            };
            stackLayout.Children.Add(explanation2, FixSize);

            var goodControl = new CustomControl(Tizen.Program.ElmWindow)
            {
                Text     = "This control has correct sizing - it occupies the available size of the device - (one two three four five six).",
                FontSize = 28
            };
            stackLayout.Children.Add(goodControl, FixSize);
#endif
        }