.NET Framework Class Library
RepeatButton Class

Updated: November 2007

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:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/xaml/presentation

Visual Basic (Declaration)
Public Class RepeatButton _
    Inherits ButtonBase
Visual Basic (Usage)
Dim instance As RepeatButton
C#
public class RepeatButton : ButtonBase
Visual C++
public ref class RepeatButton : public ButtonBase
J#
public class RepeatButton extends ButtonBase
JScript
public class RepeatButton extends ButtonBase
XAML Object Element Usage
<RepeatButton>
  Content
</RepeatButton>

Content Model: RepeatButton is a ContentControl. Its content property is Content. For more information on the content model for RepeatButton, see Controls Content Model Overview.

The RepeatButton class represents a control that is similar to 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 begins. You can also control the interval of the repetitions with the Interval property.

The following example shows how to create a RepeatButton.

C#
<RepeatButton Width="100" DockPanel.Dock="Top" 
              Delay="500" Interval="100" 
              Click="Increase">
  Increase
</RepeatButton>

<TextBlock Name="valueText" 
           Width="100" DockPanel.Dock="Top" 
           TextAlignment="Center" FontSize="16">
  0
</TextBlock>

<RepeatButton Width="100" DockPanel.Dock="Top" 
              Delay="500" Interval="100" 
              Click="Decrease">
  Decrease
</RepeatButton>


...


void Increase(object sender, RoutedEventArgs e)
{
    Int32 Num = Convert.ToInt32(valueText.Text);

    valueText.Text = ((Num + 1).ToString());
}

void Decrease(object sender, RoutedEventArgs e)
{
    Int32 Num = Convert.ToInt32(valueText.Text);

    valueText.Text = ((Num - 1).ToString());
}

Visual Basic
Private Sub Increase(ByVal sender As Object, ByVal e As RoutedEventArgs)

    Num = CInt(valueText.Text)

    valueText.Text = ((Num + 1).ToString())
End Sub

Private Sub Decrease(ByVal sender As Object, ByVal e As RoutedEventArgs)

    Num = CInt(valueText.Text)

    valueText.Text = ((Num - 1).ToString())
End Sub

System..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows.Media..::.Visual
        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.

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Page view tracker