New Events in Silverlight 4 in C#.NET

Creating QR Code JIS X 0510 in C#.NET New Events in Silverlight 4

New Events in Silverlight 4
QR Code 2d Barcode Maker In Visual C#.NET
Using Barcode printer for .NET Control to generate, create Denso QR Bar Code image in Visual Studio .NET applications.
www.OnBarcode.com
QR-Code Scanner In C#.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
With the release of Silverlight 4, there is now support for some new events that make for better User Experiences (UX) and all around better Rich Internet Applications (RIAs) in general. Let s explore some of these new events.
Barcode Creator In C#.NET
Using Barcode encoder for VS .NET Control to generate, create Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Encoding Matrix In Visual C#.NET
Using Barcode generation for .NET Control to generate, create 2D Barcode image in VS .NET applications.
www.OnBarcode.com
Right-Click
GS1 128 Drawer In C#
Using Barcode creation for .NET Control to generate, create UCC-128 image in .NET framework applications.
www.OnBarcode.com
Code 128B Generator In C#.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Code 128 Code Set C image in .NET framework applications.
www.OnBarcode.com
Right-click is an event that was added with the release of Silverlight 4 and is one that is a very important part of allowing Silverlight to behave like typical desktop software applications such as Microsoft Word. In Word you know that if you right-click something you often get some kind of contextual menu that allows you to perform certain actions such as changing the size of the font. Figure 9-17 shows what happens when you right-click text in Microsoft Word.
Draw Linear 1D Barcode In Visual C#.NET
Using Barcode generator for .NET framework Control to generate, create Linear image in .NET framework applications.
www.OnBarcode.com
Generate ANSI/AIM Code 93 In Visual C#.NET
Using Barcode encoder for Visual Studio .NET Control to generate, create Code 93 image in .NET framework applications.
www.OnBarcode.com
Download from Wow! eBook <www.wowebook.com>
Encoding QR Code JIS X 0510 In None
Using Barcode generation for Online Control to generate, create QR Code 2d barcode image in Online applications.
www.OnBarcode.com
Printing Denso QR Bar Code In Objective-C
Using Barcode encoder for iPhone Control to generate, create QR Code image in iPhone applications.
www.OnBarcode.com
Figure 9-17. Right-clicking text in Microsoft Word brings up this contextual menu. To show how Silverlight 4 s new Right-click event can be useful, let s try and make our application do something similar to what Word does. To start create an image like I have in Figure 9-17, save it to your hard drive and return to Blend.
data matrix excel add in
Using Barcode generation for Microsoft Excel Control to generate, create ECC200 image in Excel applications. free barcode add in for excel 2013 data matrix excel add in
www.OnBarcode.com
Code 3/9 Scanner In C#.NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
I have uploaded my image just in case you don t know how or don t have time to make one: http://www.windowspresentationfoundation.com/bookDownloads/RightClickImg.jpg
Encode Code 128 In .NET Framework
Using Barcode generation for Reporting Service Control to generate, create Code-128 image in Reporting Service applications.
www.OnBarcode.com
Reading Code 3 Of 9 In .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
1. In Blend right-click on the EventsAndEventHandlers project in the Projects and click Add
Printing GS1 - 13 In Objective-C
Using Barcode drawer for iPhone Control to generate, create GS1 - 13 image in iPhone applications.
www.OnBarcode.com
Scanning QR-Code In Visual Basic .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Existing Item, as I am doing in Figure 9-18.
ANSI/AIM Code 39 Generator In Java
Using Barcode generation for BIRT reports Control to generate, create Code 3 of 9 image in BIRT applications.
www.OnBarcode.com
Barcode Generation In Java
Using Barcode maker for BIRT reports Control to generate, create Barcode image in BIRT applications.
www.OnBarcode.com
EVENTS AND EVENTHANDLERS
Data Matrix ECC200 Printer In None
Using Barcode creator for Software Control to generate, create ECC200 image in Software applications.
www.OnBarcode.com
UPC-A Supplement 2 Generation In None
Using Barcode creation for Online Control to generate, create UPC A image in Online applications.
www.OnBarcode.com
Figure 9-18. Add Existing Item to the project.
2. Navigate to where you saved your image that looks like Figure 9-17 and double-click it to add it
to the project.
3. Drag the image from the Projects panel to the artboard so that you have your image sitting on
your artboard, as shown in Figure 9-19.
Figure 9-19. Drag the image to the artboard.
4. Switch back to the Properties panel. It is probably still showing the Events, so click the
Properties icon to switch back to Properties. The Properties icon is shown in Figure 9-20:
Figure 9-20. Click the Properties icon to view the properties of the selected objects.
5. With the Image selected go to the Appearance bucket and change the Opacity property to 0
to make it invisible, as I am doing in Figure 9-21.
Figure 9-21. Change the Visibility to Collapsed for the Image.
6. Give the image a Name property of MyImage. 7. Click the Events icon in the Properties panel to view the Events again. Locate the
MouseRightButtonDown event and double-click it. Blend will create the event and event handler as shown in Figure 9-22
Figure 9-22. Create the MouseRightButtonDown event.
8. In MainPage.xaml.cs, locate the newly created event and change the Opacity to 1 (100%)
as I do here: private void Image_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { MyImage.Opacity = 1; }
EVENTS AND EVENTHANDLERS
If you didn t want the Silverlight context menu to appear you could simple write e.Handled = true; in the event handler.
9. Run the application and right-click in the area where MyImage should be if you could see it.
Notice how it appears (see Figure 9-23).
Figure 9-23. MyImage now shows up when you right-click it.
Challenge: Make MyImage have an Opacity of 0 again when you MouseRightButtonUp.
MouseWheel
MouseWheel is another important event that allows Silverlight 4 to provide the good UX that we have become so used to. For example, say we have an image that is not fully shown but has scrollbars; we know that if we use our mouse and drag the scrollbars the image will scroll. But we also have become used to the idea that if we see scrollbars we can also use our MouseWheel to scroll. As it turns out Microsoft has made the implementation of this event quite easy. Any object that can have scrollbars, such as a ScrollViewer, ListBox, or DataGrid already has MouseWheel implemented, and we don t have to write any special code to make it work; it just does out of the box. But we can write code to use MouseWheel on items that don t have scrollbars. For instance, we could use the MouseWheel event to change the size of an object say, a Rectangle. Let s do that now.
1. In Blend create a Rectangle with an explicit Height and Width of 100 and a solid red fill, as I
have done in Figure 9-24.
Figure 9-24. A Rectangle with a red fill.
2. In the Properties panel name the new Rectangle MyRect. 3. Switch to the Events tab in the Properties panel and, with MyRect still selected, double-click
the MouseWheel property to create the event handler in the Mainpage code-behind.
4. In the MouseWheel event handler add the code to change the Height of the Rectangle, as I do
here: private void MyRect_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) { // TODO: Add event handler implementation here. double RectHeight = MyRect.Height; double RectWidth = MyRect.Width; int delta = e.Delta; } If you run the application now you will see that when you click the red Rectangle and then scroll your MouseWheel up and down, you can change the Height of the Rectangle. Pretty cool, huh
Copyright © OnBarcode.com . All rights reserved.