Windows.UI.Xaml.Media.LinearGradientBrush GenerateBrush()
        {
            var result = new Windows.UI.Xaml.Media.LinearGradientBrush(new Windows.UI.Xaml.Media.GradientStopCollection
            {
                new Windows.UI.Xaml.Media.GradientStop {
                    Color = Element.StartColor.ToWindowsColor(), Offset = 0
                },
                new Windows.UI.Xaml.Media.GradientStop {
                    Color = Element.EndColor.ToWindowsColor(), Offset = 1
                }
            }, Element.Orientation == Xamarin.Forms.StackOrientation.Horizontal ? 0 : 90);

            return(result);
        }
Пример #2
0
        private void SetColors()
        {
            var oriBrush = (Element as BrushLabel)?.Foreground as LinearGradientBrush;

            if (oriBrush != null)
            {
                var collections = new Windows.UI.Xaml.Media.GradientStopCollection();
                foreach (var stop in oriBrush.GradientStops)
                {
                    collections.Add(new Windows.UI.Xaml.Media.GradientStop()
                    {
                        Color = stop.Color.ToWindowsColor(), Offset = stop.Offset
                    });
                }
                var brush = new Windows.UI.Xaml.Media.LinearGradientBrush
                {
                    GradientStops = collections,
                    StartPoint    = oriBrush.StartPoint.ToWindows(),
                    EndPoint      = oriBrush.EndPoint.ToWindows()
                };
                Control.Foreground = brush;
            }
        }
Пример #3
0
        public BrokenNativeControl()
        {
            _textBlock = new TextBlock {
                MinHeight           = 0,
                MaxHeight           = double.PositiveInfinity,
                MinWidth            = 0,
                MaxWidth            = double.PositiveInfinity,
                FontSize            = 24,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Children.Add(_textBlock);

            Background =
                new WLinearGradientBrush(
                    new WGradientStopCollection {
                new WGradientStop {
                    Color = Colors.Green, Offset = 0.5
                }, new WGradientStop {
                    Color = Colors.Blue, Offset = 1
                }
            }, 0);
        }