ButtonBase.ClickMode 속성

정의

Click 이벤트가 발생하는 경우 디바이스 동작을 나타내는 값을 가져오거나 설정합니다.

public:
 property ClickMode ClickMode { ClickMode get(); void set(ClickMode value); };
ClickMode ClickMode();

void ClickMode(ClickMode value);
public ClickMode ClickMode { get; set; }
var clickMode = buttonBase.clickMode;
buttonBase.clickMode = clickMode;
Public Property ClickMode As ClickMode
<button ClickMode="clickModeMemberName"/>

속성 값

Click 이벤트가 발생하는 시기를 나타내는 열거형의 값입니다.

예제

다음 예제에서는 ClickMode 속성 값에 따라 세 가지 방법으로 클릭에 응답하는 3개의 단추를 보여 줍니다.

  • 가리키기 - 마우스 포인터가 첫 번째 단추 위로 마우스를 가져가면 단추의 전경색이 변경됩니다.
  • 누르기 - 두 번째 단추 위에 있는 동안 마우스 왼쪽 단추를 누르면 단추의 전경색이 변경됩니다.
  • 릴리스 - 세 번째 단추 위에 있는 동안 마우스 단추를 누르고 놓으면 단추는 다른 두 단추의 전경색을 원래 색으로 다시 설정합니다.
<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

적용 대상

추가 정보