Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 2.54 KB

File metadata and controls

69 lines (54 loc) · 2.54 KB
-api-id -api-type
T:Microsoft.UI.Xaml.Controls.Primitives.RepeatButton
winrt class

Microsoft.UI.Xaml.Controls.Primitives.RepeatButton

-description

Represents a control that raises its Click event repeatedly when it is pressed and held.

-xaml-syntax

<RepeatButton .../>
-or-
<RepeatButton>
    singleObject
</RepeatButton>
-or-
<RepeatButton ...>stringContent</RepeatButton>

-remarks

A RepeatButton is a button that raises Click events repeatedly from the time it is pressed until it is released. Set the Delay property to specify the time that the RepeatButton waits after it is pressed before it starts repeating the click action. Set the Interval property to specify the time between repetitions of the click action. Times for both properties are specified in milliseconds.

-examples

Tip

For more info, design guidance, and code examples, see Buttons.

[!div class="nextstepaction"] Open the WinUI 3 Gallery app and see the RepeatButton in action.

The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.

The following example shows two RepeatButton controls whose respective Click events are used to increase and decrease the value shown in a TextBlock.

<StackPanel>
    <RepeatButton Width="100" Delay="500" Interval="100" Click="Increase_Click">Increase</RepeatButton>
    <RepeatButton Width="100" Delay="500" Interval="100" Click="Decrease_Click">Decrease</RepeatButton>
    <TextBlock x:Name="clickTextBlock" Text="Number of Clicks:"/>
</StackPanel>
private static int _clicks = 0;
private void Increase_Click(object sender, RoutedEventArgs e)
{
    _clicks += 1;
    clickTextBlock.Text = "Number of Clicks: " + _clicks;
}

private void Decrease_Click(object sender, RoutedEventArgs e)
{
    if(_clicks > 0)
    {
        _clicks -= 1;
        clickTextBlock.Text = "Number of Clicks: " + _clicks;
    }
}

-see-also

ButtonBase