static public void ReadOnlyProperties(ButtonBase bb) { Assert.IsFalse((bool)bb.GetValue(ButtonBase.IsFocusedProperty), "Get/IsFocusedProperty"); Assert.IsFalse((bool)bb.GetValue(ButtonBase.IsMouseOverProperty), "Get/IsMouseOverProperty"); Assert.IsFalse((bool)bb.GetValue(ButtonBase.IsPressedProperty), "Get/IsPressedProperty"); Assert.Throws <InvalidOperationException> (delegate { bb.SetValue(ButtonBase.IsFocusedProperty, true); }); Assert.IsFalse(bb.IsFocused, "IsFocused"); Assert.Throws <InvalidOperationException> (delegate { bb.SetValue(ButtonBase.IsMouseOverProperty, true); }); Assert.IsFalse(bb.IsMouseOver, "IsMouseOver"); Assert.Throws <InvalidOperationException> (delegate { bb.SetValue(ButtonBase.IsPressedProperty, true); }); Assert.IsFalse(bb.IsPressed, "IsPressed"); bb.ClearValue(ButtonBase.IsFocusedProperty); bb.ClearValue(ButtonBase.IsMouseOverProperty); bb.ClearValue(ButtonBase.IsPressedProperty); }
private static void UnhookCommand(ButtonBase element, ICommand command) { var behavior = (CommandButtonBehavior)element.GetValue(CommandButtonBehaviorProperty); behavior.Dettach(); element.ClearValue(CommandButtonBehaviorProperty); }
/// <summary> /// Gets the value of the ConfigData attached property for a specified ButtonBase. /// </summary> /// <param name="element">The ButtonBase from which the property value is read.</param> /// <returns>The ConfigData property value for the ButtonBase.</returns> public static string GetConfigData(ButtonBase element) { if (element == null) { throw new ArgumentNullException("element"); } return element.GetValue(ConfigDataProperty) as string; }
public static object GetCommandParameter(ButtonBase buttonBase) { if (buttonBase == null) { throw new System.ArgumentNullException("buttonBase"); } return(buttonBase.GetValue(CommandParameterProperty)); }
public static ICommand GetCommand(ButtonBase buttonBase) { if (buttonBase == null) { throw new System.ArgumentNullException("buttonBase"); } return(buttonBase.GetValue(CommandProperty) as ICommand); }
private static ButtonBaseClickCommandBehavior GetOrCreateBehavior(ButtonBase buttonBase) { ButtonBaseClickCommandBehavior behavior = buttonBase.GetValue(ClickCommandBehaviorProperty) as ButtonBaseClickCommandBehavior; if (behavior == null) { behavior = new ButtonBaseClickCommandBehavior(buttonBase); buttonBase.SetValue(ClickCommandBehaviorProperty, behavior); } return(behavior); }
private static ClickedBehavior GetOrCreateBehavior(ButtonBase element) { var behavior = element.GetValue(ClickedBehaviorProperty) as ClickedBehavior; if (behavior == null) { behavior = new ClickedBehavior(element); element.SetValue(ClickedBehaviorProperty, behavior); } return(behavior); }
/// <summary> /// Gets the command name associated with the specified Button. /// </summary> /// <param name="button">The Button to lookup.</param> /// <returns>The command name associated with the Button; null if there is none.</returns> public static string GetCommand(ButtonBase button) { BehaviorCollection behaviors = (BehaviorCollection)button.GetValue(BehaviorsProperty); if (behaviors != null) { foreach (Behavior behavior in behaviors) { Command commandBehavior = behavior as Command; if (commandBehavior != null) { return(commandBehavior.CommandName); } } } return(null); }
/// <summary> /// Gets the action associated with the specified Button. /// </summary> /// <param name="button">The Button to lookup.</param> /// <returns>The action associated with the Button; null if there is none.</returns> public static TriggerAction GetAction(ButtonBase button) { TriggerCollection triggers = (TriggerCollection)button.GetValue(TriggersProperty); if (triggers != null) { foreach (Trigger trigger in triggers) { ClickTrigger clickTrigger = trigger as ClickTrigger; if (clickTrigger != null) { return(clickTrigger.Action); } } } return(null); }
protected override string GetNameCore() { ButtonBase buttonBase = Owner as ButtonBase; // Only when Content is TextBlock TextBlock.Name is returned string name = buttonBase.Content as string; if (name == null) { TextBlock textblock = buttonBase.Content as TextBlock; if (textblock == null) { name = string.Empty; } else { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(textblock); name = peer.GetName(); } } return(buttonBase.GetValue(AutomationProperties.NameProperty) as string ?? name); }
public static bool GetIsIndeterminate(ButtonBase element) => (bool)element.GetValue(IsIndeterminateProperty);
public static Brush GetIndicatorBackground(ButtonBase element) => (Brush)element.GetValue(IndicatorBackgroundProperty);
public static string GetButtonName(ButtonBase button) => (string)button.GetValue(ButtonNameProperty);
public static Geometry GetGeometry(this ButtonBase element) { return((Geometry)element.GetValue(GeometryProperty)); }
public static DialogButton GetButtonResult(ButtonBase d) { return((DialogButton)d.GetValue(ButtonResultProperty)); }
public static string GetStateControl(ButtonBase button) => (string)button.GetValue(StateControlProperty);
public static ShortcutName GetClick(ButtonBase attached) { return((ShortcutName)attached.GetValue(ClickProperty)); }
public static bool GetIsIndicatorVisible(ButtonBase element) => (bool)element.GetValue(IsIndicatorVisibleProperty);
public static double GetOpacity(ButtonBase element) => (double)element.GetValue(OpacityProperty);
public static object GetCommandParameter(ButtonBase button) { return(button.GetValue(CommandParameterProperty)); }
public static FlyoutControl GetFlyout(ButtonBase button) => (FlyoutControl)button.GetValue(FlyoutProperty);
public static bool GetInvokeCommandOnFirstLoad(ButtonBase btn) { return((bool)btn.GetValue(InvokeCommandOnFirstLoadProperty)); }
public static ButtonColorScheme GetScheme(ButtonBase obj) => (ButtonColorScheme)obj.GetValue(SchemeProperty);
public static double GetValue(ButtonBase element) => (double)element.GetValue(ValueProperty);
public static ICommand GetCommand(ButtonBase buttonBase) { return(buttonBase.GetValue(CommandProperty) as ICommand); }
public static string GetVisualState(ButtonBase frameworkElement) => (string)frameworkElement.GetValue(VisualStateProperty);
public static ICommand GetCommand(ButtonBase button) { return((ICommand)button.GetValue(CommandProperty)); }
public static UIElement GetTarget(ButtonBase b) => (UIElement)b.GetValue(TargetProperty);
public static object GetCommandParameter(ButtonBase target) => target.GetValue(CommandParameterProperty);
private void SetIsEnabled(ButtonBase element) { element.IsEnabled = command.CanExecute(element.GetValue(Commands.CommandParameterProperty)); }