ButtonBase.IsPressed 屬性


取得值,這個值表示 ButtonBase 目前是否已啟動。Gets a value that indicates whether a ButtonBase is currently activated.

public:  property bool IsPressed {  public:
bool get(); protected:
 void set(bool value); };
public bool IsPressed { get; protected set; }
member this.IsPressed : bool with get, set
Public Property IsPressed As Boolean



如果 ButtonBase 已啟動則為 true,否則為 falsetrue if the ButtonBase is activated; otherwise false. 預設值為 falseThe default is false.



這個範例示範如何使用觸發程式 IsPressed 樣式中的屬性。This example shows how to use the IsPressed property in a trigger style.

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


IsPressed 這是按鈕的狀態,表示按下滑鼠左鍵或空格鍵已按下按鈕。IsPressed is the state of a button that indicates the left mouse button or SPACEBAR is pressed over the button. IsPressed 為時 true ,控制項會捕捉滑鼠。When IsPressed is true, the control captures the mouse. 因此,控制項將會引發滑鼠事件,例如 MouseEnterIsMouseDirectlyOverChangedAs a result, the control will raise mouse events such as MouseEnter and IsMouseDirectlyOverChanged. 請注意,使用 AccessText 或 ENTER 不會變更 IsPressed 或捕捉滑鼠,而是會引發 Click 事件。Note that using the AccessText or ENTER does not change IsPressed or capture the mouse, but is does raise the Click event.

從 .NET Framework 版本 3.0 Service Pack 1 開始, IsPressed 具有受保護的 setter。Starting with the .NET Framework version 3.0 Service Pack 1, IsPressed has a protected setter. 若要使用此功能,您的應用程式應以 .NET Framework 版本3.5 為目標。To use this functionality, your application should target the .NET Framework version 3.5. 如需詳細資訊,請參閱版本和相依性For more information, see Versions and Dependencies.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field IsPressedProperty
中繼資料屬性設定為 trueMetadata properties set to true None