public DropDownButton(ActionDispatcher dispatcher, WebDropDownButtonAction action, WebIconSize iconSize)
        {
            InitializeComponent();

            _iconSize         = iconSize;
            _actionDispatcher = dispatcher;
            _actionItem       = action;

            dispatcher.Register(_actionItem.Identifier, this);

            SetIcon();

            ToolTipService.SetToolTip(StackPanelVerticalComponent, _actionItem.ToolTip);

            ButtonComponent.Click     += OnClick;
            DropButtonComponent.Height = ButtonComponent.Height;
            DropButtonComponent.Click += OnDropClick;

            _dropMenu = MenuBuilder.BuildContextMenu(action, _actionDispatcher);

            StackPanelVerticalComponent.MouseEnter += ButtonComponent_MouseEnter;
            StackPanelVerticalComponent.MouseLeave += ButtonComponent_MouseLeave;

            Visibility = _actionItem.DesiredVisiblility;

            ButtonComponent.IsEnabled     = _actionItem.Enabled;
            DropButtonComponent.IsEnabled = _actionItem.Enabled;

            IndicateChecked(_actionItem.IsCheckAction && _actionItem.Checked);

            OverlayCheckedIndicator.Opacity = _actionItem.IconSet.HasOverlay ? 1 : 0;
        }
        private void OnContextMenuEvent(ContextMenuEvent @event)
        {
            if (PopupHelper.IsPopupActive)
            {
                return;
            }

            if (_menu != null)
            {
                _menu.Dispose();
                _menu = null;
            }

            if (!IsSelected) //if we're not the selected one anymore, don't show it.
            {
                return;
            }

            _menu = MenuBuilder.BuildContextMenu(@event.ActionModelRoot, _eventMediator);
            _menu.Open(TransformToVisual(null).Transform(_rightClickPosition));
        }
 public void Update(PropertyChangedEvent e)
 {
     if (e.PropertyName.Equals("Available"))
     {
         _actionItem.Visible = (bool)e.Value;
         Visibility          = _actionItem.DesiredVisiblility;
     }
     else if (e.PropertyName.Equals("Visible"))
     {
         _actionItem.Visible = (bool)e.Value;
         Visibility          = _actionItem.DesiredVisiblility;
     }
     else if (e.PropertyName.Equals("Enabled"))
     {
         _actionItem.Enabled           = (bool)e.Value;
         ButtonComponent.IsEnabled     = _actionItem.Enabled;
         DropButtonComponent.IsEnabled = _actionItem.Enabled;
         if (_actionItem.Checked && !_actionItem.Enabled)
         {
             CheckedIndicator.Opacity = 0.25;
             if (_actionItem.IconSet.HasOverlay)
             {
                 OverlayCheckedIndicator.Opacity = 0.25;
             }
         }
         else if (_actionItem.Checked)
         {
             CheckedIndicator.Opacity = 1;
             if (_actionItem.IconSet.HasOverlay)
             {
                 OverlayCheckedIndicator.Opacity = 1;
             }
         }
         else
         {
             IndicateChecked(false);
         }
     }
     else if (e.PropertyName.Equals("IconSet"))
     {
         _actionItem.IconSet = e.Value as WebIconSet;
         SetIcon();
     }
     else if (e.PropertyName.Equals("ToolTip"))
     {
         _actionItem.ToolTip = e.Value as string;
         ToolTipService.SetToolTip(StackPanelVerticalComponent, _actionItem.ToolTip);
     }
     else if (e.PropertyName.Equals("Label"))
     {
         _actionItem.Label = e.Value as string;
     }
     else if (e.PropertyName.Equals("Checked"))
     {
         _actionItem.Checked = (bool)e.Value;
         IndicateChecked(_actionItem.Checked);
     }
     else if (e.PropertyName.Equals("DropDownActions"))
     {
         _actionItem.DropDownActions = e.Value as Collection <WebActionNode>;
         _dropMenu.Dispose();
         _dropMenu = MenuBuilder.BuildContextMenu(_actionItem, _actionDispatcher);
     }
     UpdateLayout();
 }