.NET Framework Class Library
RepeatButton Class

Updated: February 2009

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/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax

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
JScript
public class RepeatButton extends ButtonBase
XAML Object Element Usage
<RepeatButton>
  Content
</RepeatButton>
Remarks

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.

Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.

Examples

The following example shows how to create a RepeatButton.

XAML
<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>
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
C#
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());
}
Inheritance Hierarchy

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
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Change History

Date

History

Reason

February 2009

Described how default styles change dependency properties.

Customer feedback.

Tags :


Page view tracker