Ejemplo n.º 1
0
        public static void UpdateTextColor(this ButtonBase platformButton, ITextStyle button)
        {
            var brush = button.TextColor?.ToPlatform();

            if (brush is null)
            {
                // Windows.Foundation.UniversalApiContract < 5
                platformButton.Resources.Remove("ButtonForeground");
                platformButton.Resources.Remove("ButtonForegroundPointerOver");
                platformButton.Resources.Remove("ButtonForegroundPressed");
                platformButton.Resources.Remove("ButtonForegroundDisabled");

                // Windows.Foundation.UniversalApiContract >= 5
                platformButton.ClearValue(Button.ForegroundProperty);
            }
            else
            {
                // Windows.Foundation.UniversalApiContract < 5
                platformButton.Resources["ButtonForeground"]            = brush;
                platformButton.Resources["ButtonForegroundPointerOver"] = brush;
                platformButton.Resources["ButtonForegroundPressed"]     = brush;
                platformButton.Resources["ButtonForegroundDisabled"]    = brush;

                // Windows.Foundation.UniversalApiContract >= 5
                platformButton.Foreground = brush;
            }
        }
Ejemplo n.º 2
0
        private static void UnhookCommand(ButtonBase element, ICommand command)
        {
            CommandButtonBehavior behavior = (CommandButtonBehavior)element.GetValue(CommandButtonBehaviorProperty);

            behavior.Dettach();
            element.ClearValue(CommandButtonBehaviorProperty);
        }
Ejemplo n.º 3
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();
        }