ClickMode 枚举

定义

指定应何时引发 Click 事件。

public enum class ClickMode
public enum ClickMode
type ClickMode = 
Public Enum ClickMode
继承
ClickMode

字段

Hover 2

指定当鼠标悬停在控件上时应引发 Click 事件。

Press 1

指定当按下按钮时应引发 Click 事件。

Release 0

指定当按下和释放按钮时应引发 Click 事件。

示例

以下示例显示了三个按钮,这些按钮以三种不同的方式响应单击。

  • 悬停 - 当用户将鼠标悬停在按钮上时,第一个按钮将更改颜色。

  • 按 - 第二个按钮要求在鼠标指针位于按钮中时按下鼠标。

  • 释放 - 在按下鼠标并在按钮中松开之前,第三个按钮不会重置按钮的背景色。

<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;
}
Private Sub OnClick1(ByVal sender As Object, ByVal e As RoutedEventArgs)
    btn1.Background = Brushes.LightBlue
End Sub

Private Sub OnClick2(ByVal sender As Object, ByVal e As RoutedEventArgs)
    btn2.Background = Brushes.Pink
End Sub

Private Sub OnClick3(ByVal sender As Object, ByVal e As RoutedEventArgs)
    btn1.Background = Brushes.Pink
    btn2.Background = Brushes.LightBlue
End Sub

适用于