Export (0) Print
Expand All
Expand Minimize

ClickMode Enumeration

Specifies when the Click event should be raised for a control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public Enumeration ClickMode
<object property="enumMemberName"/>

Member nameDescription
Supported by Silverlight for Windows PhoneReleaseSpecifies that the Click event should be raised when the left mouse button is pressed and released, and the mouse pointer is over the control. If you are using the keyboard, specifies that the Click event should be raised when the SPACEBAR or ENTER key is pressed and released, and the control has keyboard focus.
Supported by Silverlight for Windows PhonePressSpecifies that the Click event should be raised when the mouse button is pressed and the mouse pointer is over the control. If you are using the keyboard, specifies that the Click event should be raised when the SPACEBAR or ENTER is pressed and the control has keyboard focus.
Supported by Silverlight for Windows PhoneHoverSpecifies that the Click event should be raised when the mouse pointer moves over the control.

The following example demonstrates the ClickMode enumeration.

  • Hover - When the mouse pointer hovers over the first button, the foreground color of the button changes.

  • Press - When the left mouse button is pressed while over the second button, the foreground color of the button changes.

  • Release - When the mouse button is pressed and released while over 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="White" Margin="10">
          <Button x:Name="btn1" Margin ="5" 
            HorizontalAlignment="Left"
		    Foreground="Green" Width="120" 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" 
            HorizontalAlignment="Left" 
		    Foreground="Blue" Width="120" 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" 
            HorizontalAlignment="Left"
		    Click="OnClick3" Width="120" Content="Reset" 
            ClickMode="Release"/>
        <TextBlock x:Name="text3" Margin ="0,8,0,0" />
    </StackPanel>


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft