Пример #1
0
        /// <summary>
        /// <see cref="T:Xamarin.Forms.Platform.Android.AppCompat.SwitchRenderer"/> override that is called whenever the associated
        /// <see cref="T:Xamarin.Forms.Switch"/> instance changes
        /// </summary>
        /// <param name="e"><see cref="T:Xamarin.Forms.Platform.Android.ElementChangedEventArgs"/> that specifies the
        /// previously and newly assigned <see cref="T:Xamarin.Forms.Switch"/> instances
        /// </param>
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs <Xamarin.Forms.Switch> e)
        {
            base.OnElementChanged(e);

            _properties = (e.NewElement != null) ? new SwitchGloss(e.NewElement) : null;

            Control.UpdateColorProperty(_properties, null);
        }
Пример #2
0
        /// <summary>
        /// <see cref="T:Xamarin.Forms.Platform.iOS.SwitchRenderer"/> override that is called whenever the associated
        /// <see cref="T:Xamarin.Forms.Switch"/> instance changes
        /// </summary>
        /// <param name="e"><see cref="T:Xamarin.Forms.Platform.iOS.ElementChangedEventArgs"/> that specifies the
        /// previously and newly assigned <see cref="T:Xamarin.Forms.Switch"/> instances
        /// </param>
        protected override void OnElementChanged(ElementChangedEventArgs <Switch> e)
        {
            base.OnElementChanged(e);

            _properties = (e.NewElement != null) ? new SwitchGloss(e.NewElement) : null;

            if (Control != null && _properties != null)
            {
                Control.UpdateColorProperty(_properties, null);
            }
        }
Пример #3
0
        StackLayout CreateThumbOnTintColorSwitch(string colorName, Color colorValue)
        {
            var result = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(10),
                Children    =
                {
                    new Label()
                    {
                        Text = colorName,
                        HorizontalOptions = LayoutOptions.StartAndExpand
                    }
                }
            };

            var control = new Switch();

            SwitchGloss.SetThumbOnTintColor(control, colorValue);

            result.Children.Add(control);

            return(result);
        }