共用方式為


ClickMode 列舉

定義

指定控制項應該引發 Click 事件的時間。

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"/>
繼承
ClickMode
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

欄位

Hover 2

指定當滑鼠指標移到控制項上方時,應該引發 Click 事件。

Press 1

指定按下滑鼠按鍵且滑鼠指標位於控制項上方時,應該引發 Click 事件。 如果您使用鍵盤,請指定按下空格鍵或 ENTER 鍵且控制項具有鍵盤焦點時,應該引發 Click 事件。

Release 0

指定按下並放開滑鼠左鍵時,應該引發 Click 事件,而且滑鼠指標位於控制項上方。 如果您使用鍵盤,請指定當空格鍵或 ENTER 鍵按下並放開時,應該引發 Click 事件,而且控制項具有鍵盤焦點。

範例

下列範例示範 ClickMode 列舉。

  • 暫留 - 當滑鼠指標停留在第一個按鈕上時,按鈕的前景色彩會變更。
  • 按下 - 當滑鼠左鍵在第二個按鈕上方按下時,按鈕的前景色彩會變更。
  • 放開 - 按下滑鼠按鍵並在第三個按鈕上方放開時,按鈕會將其他兩個按鈕的前景色彩重設為其原始色彩。
<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

適用於