Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
RepeatButton Class

  Switch on low bandwidth view
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
RepeatButton Class

Represents a control that raises its Click event repeatedly from the time it is pressed until it is released.

Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
<TemplateVisualStateAttribute(Name := "Normal", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Focused", GroupName := "FocusStates")> _
<TemplateVisualStateAttribute(Name := "MouseOver", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Pressed", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Disabled", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Unfocused", GroupName := "FocusStates")> _
Public NotInheritable Class RepeatButton _
    Inherits ButtonBase
Visual Basic (Usage)
Dim instance As RepeatButton
C#
[TemplateVisualStateAttribute(Name = "Normal", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Focused", GroupName = "FocusStates")]
[TemplateVisualStateAttribute(Name = "MouseOver", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Pressed", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Disabled", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Unfocused", GroupName = "FocusStates")]
public sealed class RepeatButton : ButtonBase
XAML Object Element Usage
<RepeatButton .../>
-or-
<RepeatButton>
  singleObject
</RepeatButton>

XAML Values

singleObject

A single object element that declares the content.

The RepeatButton class represents a control that resembles a Button. However, repeat buttons give you control over when and how the Click event occurs. The RepeatButton raises the Click event repeatedly from the time it is pressed until it is released. The Delay property determines when the event starts. You can also control the interval of repetitions with the Interval property.

Content Model: RepeatButton is a ContentControl. Its content property is Content.

The following example demonstrates how to use a RepeatButton.

Run this sample

Visual Basic
Private Sub HandleCheck(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim rb As RadioButton = TryCast(sender, RadioButton)
    choiceTextBlock.Text = "You chose: " + rb.GroupName + ": " + rb.Name
End Sub

C#
static int Clicks = 0;
private void RepeatButton_Click(object sender, RoutedEventArgs e)
{
    Clicks += 1;
    clickTextBlock.Text = "Number of Clicks: " + Clicks;
}

<UserControl x:Class="RepeatButtonEx.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="350" Height="300">

    <StackPanel Margin="10">

        <TextBlock Text="RepeatButton Demonstration" Margin="0,20,10,20"
            FontFamily="Verdana" FontSize="18" FontWeight="Bold"
            Foreground="#FF5C9AC9" />

        <RepeatButton Content="click and hold for multiple Click events" 
           Click="RepeatButton_Click" Width="250" Margin="0,0,0,5"
           HorizontalAlignment="Left"/>
        <TextBlock x:Name="clickTextBlock" Text="Number of Clicks:" />

    </StackPanel>

</UserControl>

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows..::.UIElement
      System.Windows..::.FrameworkElement
        System.Windows.Controls..::.Control
          System.Windows.Controls..::.ContentControl
            System.Windows.Controls.Primitives..::.ButtonBase
              System.Windows.Controls.Primitives..::.RepeatButton
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker