ClickMode Wyliczenie
Definicja
public enum class ClickMode
public enum ClickMode
type ClickMode =
Public Enum ClickMode
- Dziedziczenie
Pola
Hover | 2 | Określa, że Click zdarzenie ma być wywoływane, gdy wskaźnik myszy jest przesuwany nad kontrolką.Specifies that the Click event should be raised when the mouse hovers over a control. |
Press | 1 | Określa, że Click zdarzenie ma być wywoływane zaraz po naciśnięciu przycisku.Specifies that the Click event should be raised as soon as a button is pressed. |
Release | 0 | Określa, że Click zdarzenie ma zostać zgłoszone po naciśnięciu i udostępnieniu przycisku.Specifies that the Click event should be raised when a button is pressed and released. |
Przykłady
Poniższy przykład pokazuje trzy przyciski, które reagują na kliknięcia na trzy różne sposoby.The following example shows three buttons that respond to clicks in three different ways.
Aktywowanie — pierwszy przycisk zmienia kolory po umieszczeniu wskaźnika myszy nad przyciskiem.Hover - the first button changes colors when the user hovers with the mouse over the button.
Naciśnięcie klawisza — drugi przycisk wymaga naciśnięcia przycisku myszy, gdy wskaźnik myszy znajduje się na przycisku.Press - the second button requires that the mouse be pressed while the mouse pointer is in the button.
Wersja — trzeci przycisk nie resetuje koloru tła przycisków do momentu naciśnięcia i zwolnienia przycisku myszy.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;
}
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