In this article, a discussion of several new features/controls such as Double and Triple click support, PivotViewer and ComboBox Type-Ahead. Please review the Roadmap for the series before going any further.
Included, the Roadmap for the series below as you may want to visit other sections as you learn Silverlight 5. I picked the following features as I thought that you may find them useful in your day-to-day work. If you want a specific topic covered then please leave it in the comments below.
One of the new features in Silverlight 5 is the ability to use Double and Triple Click Support. This functionality will tell you how many times the user has clicked the mouse button. The property is called ClickCount and resides in the MouseButtonEventArgs class. Let’s take a look at how to use this new feature.
Fire up a new Silverlight 5 project and give it any name that you want.
Switch over to the MainPage.xaml.cs and add the following code: (Note: You may not need the MainPage() Method section)
1: public MainPage()
2: {
3: InitializeComponent();
4: }
5:
6: private void textBlock1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
7: {
8: textBlock1.Text = e.ClickCount.ToString();
9: }
Switch back over to the MainPage.xaml and add in the following code replacing the current Grid:
1: <Grid x:Name="LayoutRoot" Background="White">
2: <Border BorderBrush="Black" BorderThickness="1" Margin="52,49,68,74" CornerRadius="10">
3: <TextBlock Height="152" HorizontalAlignment="Center" x:Name="textBlock1" Text="0" VerticalAlignment="Center" Width="244" MouseLeftButtonDown="textBlock1_MouseLeftButtonDown" Foreground="#FFFF2E2E" FontSize="96" TextAlignment="Center" />
4: </Border>
5: </Grid>
If we go ahead and run the application then we will see the following application.
Go ahead and begin clicking inside of the border and you will see the number increase. If you wait a few seconds and click again then you will notice that it reset itself. You could easily add If..Then… statements to determine what click count number they are on. This may be helpful for a 35 click Easter egg. :)
Read the full post