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) { CommandButtonBehavior behavior = (CommandButtonBehavior)element.GetValue(CommandButtonBehaviorProperty); behavior.Detach(); element.ClearValue(CommandButtonBehaviorProperty); }