Silverlight Instance Tutorial

Source: Internet
Author: User

In the previous article, we talked about the basics of Silverlight out of browser as well as custom pattern applications. In this article, we will describe the focus of Silverlight out of browser applications-creating trusted applications, also known as trusted application. Early in Silverlight 3,silverlight out of browser's functionality is not good enough to meet the user's normal access requirements because of restricted permissions, and can only be achieved by leaving the Web application out of the browser. In Silverlight 4, the capability of Silverlight out of browser is greatly enhanced by promoting application trust permissions, where permissions allow users to have access to local directories, or to execute local applications, and by invoking COM components, To achieve more powerful local application operations. Here we will talk about the Silverlight out of browser trusted application-access to the local file system.

In this article, we will perform a demonstration based on the project Silverlightoobdemo provided in the previous tutorial.

First you need to confirm that the Silverlightoobdemo project allows the user to elevate the application trust permissions. In this way, the OOB application is allowed to access user local resources.

Silverlight 4 access to local folders does not represent access to all local disk directories, so far the Silverlight 4 API only supports access to My Documents, my music, My Pictures and my Videos directories, and program Files and Cookies directory, and if you want to access all of the disk directories, you need to use the COM feature, and we will focus on how the Silverlight 4 API operates on the "my" family catalog in the next installment.

Before you implement specific functionality, you first need to add two new files to your project, one for the resource file Resources.xaml, which is referenced from the source Control Blacklight resource style, primarily to create new buttons to demonstrate the effect, as shown in the following illustration:

Another is the small picture control Thumbimage.xaml, which is used to load the "My Pictures" directory after a thumbnail image, the code is simpler,

1 <UserControl  x:Class="SilverlightOOBDemo.ThumbImage"
2      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5      xmlns:mc="http://schemas.openxmlformats.org/markup- compatibility/2006"
6     mc:Ignorable="d"
7      d:DesignHeight="300" d:DesignWidth="400">
8
9      <Grid x:Name="LayoutRoot" Margin="10">
10          <Image x:Name="ThumbnailImage" Height="145"  Width="225" />
11     </Grid>
12  </UserControl>

1 namespace SilverlightOOBDemo
2 {
3     public  partial class ThumbImage : UserControl
4     {
5          private Image _OriginalImage;
6          public Image OriginalImage 
7         { 
8              get 
9             {
10                  return _OriginalImage; 
11              } 
12             set 
13              {
14                 this._OriginalImage  = value;
15                  ThumbnailImage.Source = new WriteableBitmap(_OriginalImage, null);  
16             } 
17         }
18
19         public ThumbImage()
20          {
21             InitializeComponent();
22          }
23     }
24 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.