ClickMode Enum

Definition

Specifies when the Click event should be raised.

public enum ClickMode
Inheritance
ClickMode

Fields

Name Value Description
Release 0

Specifies that the Click event should be raised when a button is pressed and released.

Press 1

Specifies that the Click event should be raised as soon as a button is pressed.

Hover 2

Specifies that the Click event should be raised when the mouse hovers over a control.

Examples

The following example shows three buttons that respond to clicks in three different ways.

  • Hover - the first button changes colors when the user hovers with the mouse over the button.

  • Press - the second button requires that the mouse be pressed while the mouse pointer is in the button.

  • Release - the third button does not reset the background color of the buttons until the mouse is pressed and released in the button.

<Button Name="btn1" Background="Pink" 
        BorderBrush="Black" BorderThickness="1" 
        Click="OnClick1" ClickMode="Hover">
  ClickMe1
</Button>

<Button Name="btn2" Background="LightBlue" 
        BorderBrush="Black" BorderThickness="1" 
        Click="OnClick2" ClickMode="Press">
  ClickMe2
</Button>

<Button Name="btn3" 
        Click="OnClick3" ClickMode="Release">
  Reset
</Button>
void OnClick1(object sender, RoutedEventArgs e)
{
    btn1.Background = Brushes.LightBlue;
}

void OnClick2(object sender, RoutedEventArgs e)
{
    btn2.Background = Brushes.Pink;
}

void OnClick3(object sender, RoutedEventArgs e)
{
    btn1.Background = Brushes.Pink;
    btn2.Background = Brushes.LightBlue;
}

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9