本文整理汇总了C#中System.Windows.Controls.Primitives.ButtonBase类的典型用法代码示例。如果您正苦于以下问题:C# ButtonBase类的具体用法?C# ButtonBase怎么用?C# ButtonBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ButtonBase类属于System.Windows.Controls.Primitives命名空间,在下文中一共展示了ButtonBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadOnlyProperties
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);
}
示例2: ButtonBaseAutomationPeer
protected ButtonBaseAutomationPeer (ButtonBase owner)
: base (owner)
{
textBlock = owner.Content as TextBlock;
if (textBlock != null)
textBlock.UIATextChanged += TextBlock_TextChanged;
}
示例3: ButtonBackend
protected ButtonBackend(ButtonBase impl)
{
if (impl == null)
throw new ArgumentNullException ("impl");
Widget = impl;
}
示例4: SetConfigData
/// <summary>
/// Sets the value of the ConfigData attached property to a specified ButtonBase.
/// </summary>
/// <param name="element">The ButtonBase to which the attached property is written.</param>
/// <param name="value">The needed ConfigData value.</param>
public static void SetConfigData(ButtonBase element, string value)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.SetValue(ConfigDataProperty, value);
}
示例5: AddButtonToMap
internal void AddButtonToMap(ButtonBase btn, ICommand cmd)
{
if (!ContainsCommand(cmd))
_map.Add(new WeakReference(cmd), new List<WeakReference>());
List<WeakReference> weakRefs = GetButtonsFromCommand(cmd);
weakRefs.Add(new WeakReference(btn));
}
示例6: GetConfigData
/// <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;
}
示例7: AddButtonToMap
internal void AddButtonToMap(ButtonBase button, ICommand comand)
{
if (!ContainsCommand(comand))
{
_map.Add(new WeakReference(comand), new List<WeakReference>());
}
var weakRefs = GetButtonsFromCommand(comand);
weakRefs.Add(new WeakReference(button));
}
示例8: GetOrCreateBehavior
private static ButtonBaseClickCommandBehavior GetOrCreateBehavior(ButtonBase buttonBase)
{
var behavior = buttonBase.GetValue(clickCommandBehaviorProperty) as ButtonBaseClickCommandBehavior;
if (behavior == null)
{
behavior = new ButtonBaseClickCommandBehavior(buttonBase);
buttonBase.SetValue(clickCommandBehaviorProperty, behavior);
}
return behavior;
}
示例9: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_textBox = GetTemplateChild(PART_TextBox) as TextBox;
_button = GetTemplateChild(PART_ButtonBase) as ButtonBase;
if (_button != null)
{
_button.Click += ButtonClick;
}
}
示例10: OnApplyTemplate
public override void OnApplyTemplate()
{
// Close Button
ButtonBase oldCloseButton = _partCloseButton;
_partCloseButton = Template.FindName("PART_CloseButton", this) as ButtonBase;
if (!ReferenceEquals(oldCloseButton, _partCloseButton))
{
if (oldCloseButton != null)
{
oldCloseButton.Click -= OnCloseButtonClick;
}
if (_partCloseButton != null)
{
_partCloseButton.Click += OnCloseButtonClick;
}
}
// Minimize Button
ButtonBase oldMinimizeButton = _partMinimizeButton;
_partMinimizeButton = Template.FindName("PART_MinimizeButton", this) as ButtonBase;
if (!ReferenceEquals(oldMinimizeButton, _partMinimizeButton))
{
if (oldMinimizeButton != null)
{
oldMinimizeButton.Click -= OnMinimizeButtonClick;
}
if (_partMinimizeButton != null)
{
_partMinimizeButton.Click += OnMinimizeButtonClick;
}
}
// Maximize Button
ButtonBase oldMaximizeButton = _partMaximizeButton;
_partMaximizeButton = Template.FindName("PART_MaximizeButton", this) as ButtonBase;
if (!ReferenceEquals(oldMaximizeButton, _partMaximizeButton))
{
if (oldMaximizeButton != null)
{
oldMaximizeButton.Click -= OnMaximizeButtonClick;
}
if (_partMaximizeButton != null)
{
_partMaximizeButton.Click += OnMaximizeButtonClick;
}
}
}
示例11: ButtonEventCheck
public ButtonEventCheck(ButtonBase ButtonBase, bool showMessageBoxFlg)
{
RoutedEventHandler handler = (s, e) =>
{
ButtonClickCalled = true;
if (showMessageBoxFlg)
{
MessageBox.Show("TestMessageWindow");
}
};
ButtonBase.Click += handler;
}
示例12: GetAction
/// <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;
}
示例13: RemoveButtonFromMap
internal void RemoveButtonFromMap(ButtonBase btn, ICommand cmd)
{
List<WeakReference> buttonRefs = this.GetButtonsFromCommand(cmd);
if (buttonRefs == null)
return;
for (int i = buttonRefs.Count - 1; i > -1; --i)
{
WeakReference weakRef = buttonRefs[i];
if (weakRef.Target == btn)
{
buttonRefs.RemoveAt(i);
break;
}
}
}
示例14: RemoveButtonFromMap
internal void RemoveButtonFromMap(ButtonBase button, ICommand command)
{
var buttonRefs = GetButtonsFromCommand(command);
if (buttonRefs == null)
{
return;
}
for (var i = buttonRefs.Count - 1; i > -1; --i)
{
var weakRef = buttonRefs[i];
if (weakRef.Target == button)
{
buttonRefs.RemoveAt(i);
break;
}
}
}
示例15: OnApplyTemplate
//--------------------------------------------------------------
/// <summary>
/// When overridden in a derived class, is invoked whenever application code or internal
/// processes call <see cref="FrameworkElement.ApplyTemplate"/>.
/// </summary>
public override void OnApplyTemplate()
{
// Clean up.
if (_button != null)
{
_button.Click -= OnButtonClick;
_button = null;
}
base.OnApplyTemplate();
// Find new button and install event handler.
_button = GetTemplateChild("PART_Button") as ButtonBase;
if (_button != null)
{
_button.Click += OnButtonClick;
}
}