Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
ButtonBase Class
 IsPressed Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ButtonBase..::.IsPressed Property

Gets a value that indicates whether a ButtonBase is currently activated. This is a dependency property.

Namespace:  System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)
Visual Basic (Declaration)
<BrowsableAttribute(False)> _
Public ReadOnly Property IsPressed As Boolean
Visual Basic (Usage)
Dim instance As ButtonBase
Dim value As Boolean

value = instance.IsPressed
C#
[BrowsableAttribute(false)]
public bool IsPressed { get; }
Visual C++
[BrowsableAttribute(false)]
public:
property bool IsPressed {
    bool get ();
}
JScript
public function get IsPressed () : boolean
XAML
You cannot set this property in XAML.

Property Value

Type: System..::.Boolean
true if the ButtonBase is activated; otherwise false. The default is false.

Identifier field

IsPressedProperty

Metadata properties set to true

None

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 .NET Framework 3.5 Architecture.

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

C#
btncsharp.FontSize = SystemFonts.CaptionFontSize;
XAML
<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>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker