ClickMode Property
Collapse the table of content
Expand the table of content

ButtonBase.ClickMode Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets when the Click event occurs.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

Public Property ClickMode As ClickMode
<button ClickMode="clickModeValue"/>

XAML Values


A named constant of the ClickMode enumeration, such as Hover.

Property Value

Type: System.Windows.Controls.ClickMode
When the Click event occurs. The default value is ClickMode.Release.

Dependency property identifier field: ClickModeProperty

Use this property to set what type of user interaction is required to raise a Click event. When a button's click mode is Hover, the Click event cannot be raised by using the keyboard.

The following example shows three buttons that respond to taps in three different ways based on their ClickMode property value.

  • Hover - When the finger is pressed to the screen outside of the control and then moves over first button, the foreground color of the button changes.

  • Press - When the finger makes contact with the second button, the foreground color of the button changes.

  • Release - When the finger presses and releases the third button, the button resets the foreground color of the other two buttons to their original color.

Private Sub OnClick1(ByVal sender As Object, ByVal e As RoutedEventArgs)
    btn1.Foreground = New SolidColorBrush(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(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(Colors.Green)
    btn2.Foreground = New SolidColorBrush(Colors.Blue)
    text1.Text = ""
    text2.Text = ""
    text3.Text = "Click event handled on Release."
End Sub

    <StackPanel x:Name="LayoutRoot" Background="Transparent" Margin="10">
          <Button x:Name="btn1" Margin ="5" 
		    Foreground="Green" Width="240" Click="OnClick1" 
		    Content="Hover to Click" ClickMode="Hover" />
        <TextBlock x:Name="text1" Margin ="0,8,0,0" />
        <Button x:Name="btn2" Margin ="5,5,5,5" 
		    Foreground="Blue" Width="240" Click="OnClick2" 
		    Content="Press to Click" ClickMode="Press" />
        <TextBlock x:Name="text2" Margin="0,8,0,0" />
        <Button x:Name="btn3" Margin ="5,5,5,5" 
		    Click="OnClick3" Width="240" Content="Reset" 
        <TextBlock x:Name="text3" Margin ="0,8,0,0" />

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2016 Microsoft