ClickMode Enum
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
public enum class ClickMode
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class ClickMode
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum ClickMode
Public Enum ClickMode
<object property="enumMemberName"/>
- Warisan
-
ClickMode
- Atribut
Persyaratan Windows
Rangkaian perangkat |
Windows 10 (diperkenalkan dalam 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)
|
Bidang
Hover | 2 | Menentukan bahwa peristiwa Klik harus dinaikkan ketika penunjuk mouse bergerak di atas kontrol. |
Press | 1 | Menentukan bahwa peristiwa Klik harus dinaikkan ketika tombol mouse ditekan dan penunjuk mouse berada di atas kontrol. Jika Anda menggunakan keyboard, menentukan bahwa peristiwa Klik harus dinaikkan saat tombol SPACEBAR atau ENTER ditekan dan kontrol memiliki fokus keyboard. |
Release | 0 | Menentukan bahwa peristiwa Klik harus dinaikkan ketika tombol mouse kiri ditekan dan dilepaskan, dan penunjuk mouse berada di atas kontrol. Jika Anda menggunakan keyboard, menentukan bahwa peristiwa Klik harus dinaikkan saat tombol SPACEBAR atau ENTER ditekan dan dilepaskan, dan kontrol memiliki fokus keyboard. |
Contoh
Contoh berikut menunjukkan enumerasi ClickMode.
- Arahkan kursor - Saat penunjuk mouse mengarah ke tombol pertama, warna latar depan tombol berubah.
- Tekan - Ketika tombol mouse kiri ditekan saat di atas tombol kedua, warna latar depan tombol berubah.
- Rilis - Ketika tombol mouse ditekan dan dilepaskan saat di atas tombol ketiga, tombol mengatur ulang warna latar depan dari dua tombol lainnya ke warna aslinya.
<StackPanel x:Name="LayoutRoot" Margin="10">
<Button x:Name="btn1" Content="Hover to Click"
Click="OnClick1" ClickMode="Hover"
Margin="5" Width="150"
HorizontalAlignment="Left"
Foreground="Green"/>
<TextBlock x:Name="text1" Margin="5,8,0,0" />
<Button x:Name="btn2" Content="Press to Click"
Click="OnClick2" ClickMode="Press"
Margin="5,5,5,5" Width="150"
HorizontalAlignment="Left"
Foreground="Blue"/>
<TextBlock x:Name="text2" Margin="5,8,0,0" />
<Button x:Name="btn3" Content="Reset"
Click="OnClick3" ClickMode="Release"
Margin="5,5,5,5" Width="150"
HorizontalAlignment="Left"/>
<TextBlock x:Name="text3" Margin="5,8,0,0" />
</StackPanel>
void OnClick1(object sender, RoutedEventArgs e)
{
btn1.Foreground = new SolidColorBrush(Windows.UI.Colors.Blue);
text1.Text = "Click event occurs on Hover.";
text2.Text = "";
text3.Text = "";
}
void OnClick2(object sender, RoutedEventArgs e)
{
btn2.Foreground = new SolidColorBrush(Windows.UI.Colors.Green);
text1.Text = "";
text2.Text = "Click event occurs on Press.";
text3.Text = "";
}
void OnClick3(object sender, RoutedEventArgs e)
{
btn1.Foreground = new SolidColorBrush(Windows.UI.Colors.Green);
btn2.Foreground = new SolidColorBrush(Windows.UI.Colors.Blue);
text1.Text = "";
text2.Text = "";
text3.Text = "Click event occurs on Release.";
}
Private Sub OnClick1(ByVal sender As Object, ByVal e As RoutedEventArgs)
btn1.Foreground = New SolidColorBrush(Windows.UI.Colors.Blue)
text1.Text = "Click event handled on Hover."
text2.Text = ""
text3.Text = ""
End Sub
Private Sub OnClick2(ByVal sender As Object, ByVal e As RoutedEventArgs)
btn2.Foreground = New SolidColorBrush(Windows.UI.Colors.Green)
text1.Text = ""
text2.Text = "Click event handled on Press."
text3.Text = ""
End Sub
Private Sub OnClick3(ByVal sender As Object, ByVal e As RoutedEventArgs)
btn1.Foreground = New SolidColorBrush(Windows.UI.Colors.Green)
btn2.Foreground = New SolidColorBrush(Windows.UI.Colors.Blue)
text1.Text = ""
text2.Text = ""
text3.Text = "Click event handled on Release."
End Sub