Beispiel #1
0
        protected override async Task <object> GetAsync(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_source))
            {
                return(null);
            }

            object icon;

            if (_parsed)
            {
                icon = await XamlTools.FromXamlStringAsync(_source).ConfigureAwait(true);
            }
            else
            {
                icon = await XamlTools.FromSvgStringAsync(_source).ConfigureAwait(true);

                _source = XamlWriter.Save(icon);
                _parsed = true;
            }

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.ToColor(), brush);
            }

            return(icon);
        }
        private static async Task <object> GetSvgIconAsync(string source, int?foreColor)
        {
            if (string.IsNullOrWhiteSpace(source))
            {
                return(null);
            }
            var icon = (UIElement)await XamlTools.FromSvgStringAsync(source).ConfigureAwait(true);

            return(new Viewbox
            {
                Child = icon,
                MaxHeight = 30
            });
        }