Button控件,从按下、保持到抬起这个过程,不论按多久都只响应一次事件,
RepeatButton只要按下并保持不松开,就会不断触发按下事件。
- <!--LayoutRoot 是包含所有页面内容的根网格-->
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <TextBlock Name="textBlock1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="50" Width="150" Text="数字" Margin="161,12,169,706"></TextBlock>
- <RepeatButton Height="70" Width="150" Content="aaa" Click="RepeatButton_Click" Margin="161,63,169,635"></RepeatButton>
- </Grid>
C#代码:
- int i = 0;
- private void RepeatButton_Click(object sender, RoutedEventArgs e)
- {
- i++;
- this.textBlock1.Text = i.ToString();
- }