2010.11.8 su Peng
Content
-Silverlight supports Drop object operations
-Right-click a menu object in Silverlight
-Print in Silverlight
Prerequisites
-Install Visual Studio 2010
-Install Expression Blend4
-Install Silverlight tools for Visual Studio 2010
-Understand C #
Drop object
-File drag and drop support
-AllowDrop attribute and Drop event
Demo
-Example of dragging an image control
Containers do not have to use WrapPanel. Other containers do.
The BitmapImage class supports only jpg and png formats.
E. Data. GetData can take out all FileInfo, including the path and name of the image file.
DroppedFile has a large security permission and does not have full restrictions on the file path. When we drag the file in, droppedFile considers that we allow it to read the file. Next, files can be read using binary streams. Therefore, be careful when developing and using files.
In addition to images, we can also read text.
Right-click menu
-MouseRightButtonDown and MouseRightButtonUp Methods
-Popup class
Demo
-Right-click menu
When we finish the click event, we need. handled is set to true. If we do not do this, the Silverlight Framework will Handle it. The Silverlight Framework itself has its right-click menu, in this way, the right-click menu is displayed. So in any case, we need to write this sentence to indicate that we will handle this matter.
Print function
-PrintDocument object
-Call PrintDocument. Print ()
Demo
-Print example
The standard function of Print does not contain parameters. If you call the Print function, you must tell the program to Print the elements in the previous PrintPage, specifies what to print through PrintPage. The parameters in Print are the name of the Print job, which can be viewed in the printer status.
Run the program and click Print. The Print settings will pop up.
Click print to display the Save location
After printing is complete, open the file and we can see the printed result.
Summary
-Silverlight supports Drop object operations
-Right-click a menu object in Silverlight
-Print in Silverlight
2010.11.26