RepeatButton
The RepeatButton is a control that has the added feature of regularly generating click events while the button is being pressed down.
Useful Properties
You will probably use these properties most often:
| Property | Description |
|---|---|
| Delay | The time (milliseconds) to wait before repeated click generation begins. Default is 300. |
| Interval | The time (milliseconds) between clicks being generated. Default is 100. |
Example
This example shows a repeat button generating click events with the default interval and delay.
- XAML
- C#
<UserControl xmlns="https://github.com/avaloniaui" Padding="20"> <RepeatButton Click="OnClick" HorizontalAlignment="Center" VerticalAlignment="Center"> Press and hold down </RepeatButton> </UserControl>
public partial class MainView : UserControl { private int _clickCount = 0; public void OnClick(object sender, RoutedEventArgs args) { var btn = (RepeatButton)sender; btn.Content = $"Clicked: {++_clickCount} times"; } }
Preview
Loading Avalonia Preview...
More Information
info
For the complete API documentation about this control, see here.
info
View the source code on GitHub RepeatButton.cs
Have questions or feedback? Join the conversation below.