Esempio n. 1
0
        private static void UpdateImageSource(CommandButton target)
        {
            if (target.IconName == null)
            {
                return;
            }

            string resourceName = "Icon_" + target.IconName;

            if (target.Size == CommandButtonSize.Large)
            {
                resourceName = "Large" + resourceName;
            }

            object source = target.FindResource(resourceName);

            target.ImageSource = source;
        }
Esempio n. 2
0
        private static void OnCommandChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            CommandButton button = (CommandButton)sender;

            if (button._enabledHandler != null)
            {
                button.Command.CanExecuteChanged -= button._enabledHandler;
            }

            button.Content = button?.UICommand?.Text;
            button.CheckEnabled();

            void EnabledHandler(object sender, EventArgs e)
            {
                button.CheckEnabled();
            }

            button._enabledHandler              = EnabledHandler;
            button.UICommand.CanExecuteChanged += EnabledHandler;
        }
Esempio n. 3
0
        private static void OnIconNameChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            CommandButton button = (CommandButton)sender;

            UpdateImageSource(button);
        }