Example #1
0
        private static void OnCommandChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Button button = dependencyObject as Button;

            if (button == null)
            {
                throw new InvalidOperationException("button required");
            }

            var command = e.NewValue as UICommand;

            if (command == null)
            {
                throw new InvalidOperationException("CommandAdapter required");
            }

            button.Name    = ClientCommand.GetProgrammingName(command.ClientCommand);
            button.Command = command;
            AutomationProperties.SetName(button, command.ClientCommand.Label);

            SetupContent(button, command);

            CommandToolTipService.SetupTooltip(button, command.ClientCommand, ToolTipStyle);
        }
Example #2
0
        private static void OnCommandChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            MenuItem menuItem = dependencyObject as MenuItem;

            if (menuItem == null)
            {
                throw new InvalidOperationException("menu item required");
            }

            var command = e.NewValue as UICommand;

            if (command == null)
            {
                throw new InvalidOperationException("CommandAdapter required");
            }

            menuItem.Name    = ClientCommand.GetProgrammingName(command.ClientCommand);
            menuItem.Command = command;
            AutomationProperties.SetName(menuItem, command.ClientCommand.Label);

            SetupContent(menuItem, command);

            CommandToolTipService.SetupTooltip(menuItem, command.ClientCommand, ToolTipStyle);
        }