Inheritance: ContentControl, IButtonBase
        public static void SetCommandFromMethod(ButtonBase target, string expression)
        {
            target.SetValue(CommandFromMethodDependencyProperty, expression);

            var method = string.Empty;
            string canExecuteWhen = null;

            var segments = expression.Split(';');
            method = segments[0];
            if (segments.Length > 1) canExecuteWhen = segments[1];

            target.DataContextChanged += (s, e) =>
            {
                target.Command = new CommandForMethod(target.DataContext, method, canExecuteWhen, null);
            };

            if( target.Command != null ) target.DataContext = new CommandForMethod(target.DataContext, method, canExecuteWhen, null);
        }
Ejemplo n.º 2
0
        public void HorizontalCenterElements(ButtonBase btn, Viewbox symbolView, ContentPresenter contentPresenter, IconPosition iconPos, double iconInterval)
        {
            if (symbolView == null || contentPresenter == null)
                return;

            switch (iconPos)
            {
                case IconPosition.Left:
                    symbolView.Margin = new Thickness(CalculateMarginWidth(btn, symbolView, contentPresenter, iconInterval), 0, 0, 0);
                    break;
                case IconPosition.Right:
                    symbolView.Margin = new Thickness(0, 0, CalculateMarginWidth(btn, symbolView, contentPresenter, iconInterval), 0);
                    break;
                case IconPosition.Top:
                    symbolView.Margin = new Thickness(0, CalculateMarginHeight(btn, symbolView, contentPresenter, iconInterval), 0, 0);
                    break;
                case IconPosition.Bottom:
                    symbolView.Margin = new Thickness(0, 0, 0, CalculateMarginHeight(btn, symbolView, contentPresenter, iconInterval));
                    break;
            }
        }
Ejemplo n.º 3
0
        protected override void OnApplyTemplate()
        {
            _expanderButton = GetTemplateChild(StringConstants.ExpanderToggleButtonPart) as ToggleButton;
            _headerButton = GetTemplateChild(StringConstants.HeaderButtonPart) as ButtonBase;
            _mainContentRow = GetTemplateChild(StringConstants.MainContentRowPart) as RowDefinition;

            if (_expanderButton != null)
            {
                _expanderButton.Checked += OnExpanderButtonChecked;
                _expanderButton.Unchecked += OnExpanderButtonUnChecked;
                _expanderButton.IsChecked = IsExpanded;
                if (IsExpanded)
                    ExpandControl();
                else
                    CollapseControl();
            }

            if (_headerButton != null)
            {
                _headerButton.Click += OnHeaderButtonClick;
            }
        }
        public void Detach()
        {
            if (_button == null)
            {
                return;
            }

            _button = null;

            ClearValue(IsPressedProperty);
        }
        public void Attach(ButtonBase button)
        {
            Detach();

            if (button == null)
            {
                return;
            }

            _button = button;
            SetBinding(
                IsPressedProperty,
                new Binding
                {
                    Source = button,
                    Path = new PropertyPath("IsPressed")
                });
        }
Ejemplo n.º 6
0
 public static void SetButton(DependencyObject element, ButtonBase value)
 {
     element.SetValue(ButtonProperty, value);
 }
Ejemplo n.º 7
0
        //SignoffStatus 3Month Button
        private void btn3MonthClick_Click(object sender, ButtonBase e)
        {
            btnmonthstatus = 3;

            GridBind(btnsentstatus, btnmonthstatus); 
        }
Ejemplo n.º 8
0
        //SignoffStatus Inbox Button
        private void btnInboxClick_Click(object sender, ButtonBase e)
        {
            btnsentstatus = "N";

            GridBind(btnsentstatus, btnmonthstatus); 
        }
 public static string GetCommandFromMethod(ButtonBase target)
 {
     var expression = target.GetValue(CommandFromMethodDependencyProperty) as string;
     return expression;
 }
Ejemplo n.º 10
0
        private static void CastAndVerifyItem(object item, out IToolStripElement element, out ButtonBase button)
        {
            if (item == null)
            {
                throw new ArgumentNullException("element", "ToolStrip.Elements doesn't accept null elements.");
            }

            element = item as IToolStripElement;

            if (element == null)
            {
                throw new ArgumentException("ToolStrip.Elements only accepts ButtonBase, IToolStripElement elements.", "element");
            }

            button = item as ButtonBase;

            if (button == null)
            {
                throw new ArgumentException("ToolStrip.Elements only accepts ButtonBase, IToolStripElement elements.", "element");
            }
        }
Ejemplo n.º 11
0
 protected ButtonBase2(object content, RoutedEventHandler click, Windows.UI.Xaml.Controls.Primitives.ButtonBase control) : this(content) {
     Click(click);
 }
Ejemplo n.º 12
0
 double CalculateMarginWidth(ButtonBase btn, Viewbox symbolView, ContentPresenter contentPresenter, double iconInterval)
 {
     var buttonPaddingWidth = btn.Padding.Left + btn.Padding.Right;
     var marginWidth = (btn.ActualWidth - iconInterval - symbolView.DesiredSize.Width - contentPresenter.DesiredSize.Width - buttonPaddingWidth) / 2;
     return Math.Max(0, marginWidth);
 }
Ejemplo n.º 13
0
 double CalculateMarginHeight(ButtonBase btn, Viewbox symbolView, ContentPresenter contentPresenter, double iconInterval)
 {
     var buttonPaddingHeight = btn.Padding.Top + btn.Padding.Bottom;
     var marginHeight = (btn.ActualHeight - iconInterval - symbolView.DesiredSize.Height - contentPresenter.DesiredSize.Height - buttonPaddingHeight) / 2;
     return Math.Max(0, marginHeight);
 }
Ejemplo n.º 14
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _expanderButton = GetTemplateChild(nameof(_expanderButton)) as ButtonBase;
            _expandedContentPresenter = GetTemplateChild(nameof(_expandedContentPresenter)) as ContentPresenter;

            _expanderButton.Click += OnExpanderButtonClick;
        }
 public ButtonBaseEvents(ButtonBase This)
     : base(This)
 {
     this.This = This;
 }