RepeatButton - Windows Phone Controls |
RepeatButton - Windows Phone Controls สำหรับ RepeatButton เป็น Control บน Windows Phone เมื่อคลิกค้างไว้ที่ปุ่ม Button จะเป็นการทำงานซ้ำ ๆ ไปเรื่อย ๆ

XAML
<RepeatButton .../>
-or-
<RepeatButton>
singleObject
</RepeatButton>
-or-
<RepeatButton ...>stringContent</RepeatButton>
Example ตัวอย่างการใช้ RepeatButton บน Windows Phone
XAML

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0" ShowGridLines="True">
<Grid>
<RepeatButton Content="click and hold for multiple Click events" Click="RepeatButton_Click" Margin="12,229,6,273" FontSize="22" />
<TextBlock x:Name="clickTextBlock" Text="Number of Clicks:" Margin="124,148,121,412" TextAlignment="Center" />
</Grid>
</Grid>
</Grid>
VB.NET
Dim Clicks As Integer = 0
Private Sub RepeatButton_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
Clicks = Clicks + 1
clickTextBlock.Text = "Number of Clicks: " & Clicks
End Sub
C#
int Clicks = 0;
private void RepeatButton_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
Clicks = Clicks + 1;
clickTextBlock.Text = "Number of Clicks: " + Clicks;
}
Screenshot

เมื่อคลิกค้างที่ RepeatButton จะเป็นการทำงานซ้ำ ๆ ใน Event นั้น ๆ

|