Edit

Share via


ButtonBase.IsPressed Property

Definition

Gets a value that indicates whether a ButtonBase is currently activated.

public:  property bool IsPressed {  public:
bool get(); protected:
 void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool IsPressed { get; protected set; }
[<System.ComponentModel.Browsable(false)>]
member this.IsPressed : bool with get, set
Public Property IsPressed As Boolean

Property Value

true if the ButtonBase is activated; otherwise false. The default is false.

Attributes

Examples

This example shows how to use the IsPressed property in a trigger style.

<Style x:Key="Triggers" TargetType="Button">
  <Style.Triggers>
    <Trigger Property="IsMouseOver" Value="true">
      <Setter Property = "Background" Value="Red"/>
    </Trigger>
    <Trigger Property="IsPressed" Value="true">
      <Setter Property = "Foreground" Value="Green"/>
    </Trigger>
  </Style.Triggers>
</Style>

Remarks

IsPressed is the state of a button that indicates the left mouse button or SPACEBAR is pressed over the button. When IsPressed is true, the control captures the mouse. As a result, the control will raise mouse events such as MouseEnter and IsMouseDirectlyOverChanged. Note that using the AccessText or ENTER does not change IsPressed or capture the mouse, but is does raise the Click event.

Starting with the .NET Framework version 3.0 Service Pack 1, IsPressed has a protected setter. To use this functionality, your application should target the .NET Framework version 3.5. For more information, see Versions and Dependencies.

Dependency Property Information

Item Value
Identifier field IsPressedProperty
Metadata properties set to true None

Applies to