Example #1
0
        public static void UpdateTextColor(this ButtonBase platformButton, Color textColor)
        {
            var brush = textColor?.ToPlatform();

            if (brush is null)
            {
                // Windows.Foundation.UniversalApiContract < 5
                platformButton.Resources.RemoveKeys(TextColorResourceKeys);
                // Windows.Foundation.UniversalApiContract >= 5
                platformButton.ClearValue(Button.ForegroundProperty);
            }
            else
            {
                // Windows.Foundation.UniversalApiContract < 5
                platformButton.Resources.SetValueForAllKey(TextColorResourceKeys, brush);
                // Windows.Foundation.UniversalApiContract >= 5
                platformButton.Foreground = brush;
            }

            platformButton.RefreshThemeResources();
        }