Repeat Button Control For Windows 10

Introduction 

 
A Repeat Button is a button that initiates click events repeatedly from the time it is pressed until it is released. 
 
Step 1
 
Open a blank app and add a Repeat Button and a Progress Bar control either from the toolbox or by copying the following XAML code into your grid.
  1. <StackPanel Margin="10,40,0,0">    
  2.     <TextBlock Text="Repeat Button" FontSize="20"></TextBlock>    
  3.     <StackPanel Orientation="Horizontal">    
  4.         <RepeatButton Name="myRepeatButton" Delay="500" Interval="100" Content="Click & Hold" Height="40" Width="120" Click="myRepeatButton_Click"></RepeatButton>    
  5.         <ProgressBar Name="myBar" Width="200" Height="8" Margin="10,0,0,0"></ProgressBar>    
  6.     </StackPanel>    
  7. </StackPanel>     
 
 
Set the Delay property to specify the time that the Repeat Button 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. The time for both properties is specified in milliseconds. 
 
Step 2
 
Copy and paste the following code to the cs page to handle the events generated on clicking.
  1. private void myRepeatButton_Click(object sender, RoutedEventArgs e)    
  2. {    
  3.     myBar.Value++;    
  4. }     
Step 3
 
Run your application and test yourself.
 
 

Summary 

 
In this article, we learned about Repeat Button Control For Windows 10. 


Similar Articles