European Silverlight 4 & Silverlight 5 Hosting BLOG

BLOG about Silverlight 5 Hosting and Its Techologies - Dedicated to European Windows Hosting Customer

Silverlight Hosting - HostForLIFE.eu :: How to get unrestricted access in Silverlight 5?

clock April 24, 2020 07:18 by author Peter

As you all know Silverlight 5 released with unrestricted access in InBrowser mode which gives full control to the Silverlight developers in the client machine. This post is to describe what are the changes you need to do at the server side as well as client side to leverage the trusted application feature.Try HostForLife.eu, only with € 3.00/month, you can get a reasonable price with best service. This topic contains only brief information about why you must use Silverlight 4. So, if you want to be more familiar with Silverlight 5, you should try HostForLife.eu

Server side

- Make the IB elevated from project properties

- Sign the xap using certificate.

Client side

- Install the cert into “trusted publishers”

- Change the reg key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight\AllowElevatedTrustAppsInBrowser” to

-The “Protected mode” of browser should be turned off for the zone.

The above steps are mainly for Silverlight 4 to Silverlight 5 conversion and want to get the full trust support. If you just upgrading your projects there is no need to do above items. Just open in Visual Studio 2010 after installing the SL 5 tools.It will show the conversion wizard and just follows that. One thing you need to make sure is the reference path to Sl 5 assemblies.

Steps to setup Silverlight 5 application to have unrestricted access in IB using elevated trust mode
Ok.Now lets look at details of how we can create new SL project which access a file from c:\ in the In-Browse mode.First as usual create a Silverlight 5 Application. Then place a Button inside and wire the Click event handler.Write the below code in the handler to write a file to c:\

private void btnWriteToCDrive_Click ( object sender, RoutedEventArgs e )

{

    File.WriteAllText(@"c:\FromSL5.txt","This is written from Silverlight 5 web application in InBrowser mode");

}

Giving Elevated trust to SL 5 application

Just to go to the Silverlight 5 project properties and in the Silverlight tab check the “Require elevated trust when running in-browser” check box.See the below screen shot for reference.

Signing the xap
Next step is to sign the xap file with a certificate. Just goto Silverlight project properties and check the “Sign the Xap File” check box.If you don’t have any certificate just create a new one using the “Create Test Certificate” button.

Disable the browser protected mode

The above changes are mainly for the server side. You need to do some at client side as well.The first one is to disable the protected mode in browser.Goto the internet options and disable it.

Change registry entry

As mentioned above just change the registry entry as it is.If you cant find the key just add a DWORD and set to 1. Still I am not sure how this step is carried out in other platforms such as MAC and Linux. That’s it.Now run your application.It will create a file inside c:\ from in browser.Just uploaded the sample by removing the certificate as it give some information about my company laptop.



European Silverlight Hosting - HostForLIFE.eu :: PopUp Control In Silverlight

clock April 17, 2020 07:20 by author Peter

Pop Up Control is a Visual Prompt Control provided in Silverlight. There are certain times when you need to really grab the user's attention. Maybe you need to display details about a critical error. Then you can just use this control. This visual prompt is designed to simulate a dialog box.
In our Sample Application we will just demonstrate how to use it.

Create a Silverlight Project

Figure 1.1 Creating Silverlight Project


Designing the Application

Here is an idea, we will add three images (ImageControls) to our application and on theirs LeftMouseButtonDown Event we will display the PopUp. So I have taken the help of Blend 3 to design the application. It will have 3 Images as Home, Search and Reports. The following figure displays our application.

Figure 1.2 Designing our Application
Adding a PopUp Control

This is actually disturbing; you can't find the control in the toolbox. But if you start typing the control name it will satisfy you. So I have added some controls like Border, StackPanel and Displaying Text and Button to close the PupUp.
    <Popup x:Name="myPopup" Margin="-34,0,-31,0" Grid.Row="2" Grid.Column="1" Height="78" VerticalAlignment="Bottom"  >    <Border CornerRadius="10" Background="Silver" BorderThickness="2" BorderBrush="Black"> 
        <StackPanel Margin="10"> 
                    <TextBlock x:Name="PopUpText"/> 
                    <Button x:Name="PopUpButton" Height="30" Width="90" Content="Close" Click="PopUpButton_Click" /> 
        </StackPanel> 
        </Border> 
    </Popup> 


PopUp Control has a unique property called IsOpen which returns a boolean value of either true or false. The default value is always false. With this concept in mind let's add some events and use this property to control the show of the PopUp.

Calling the PopUp Control
As we discussed earlier we can handle the display of the PopUp by using the property IsOpen. Now we will see how we have used in our sample application.
    private void PopUpButton_Click(object sender, RoutedEventArgs e) 
    { 
          myPopup.IsOpen = false; 
    } 
     
    private void Home_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
    { 
          PopUpText.Text = "You Clicked Home"; 
          myPopup.IsOpen = true; 
    } 
     
    private void Search_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
    { 
          PopUpText.Text = "You Clicked Search"; 
          myPopup.IsOpen = true; 
    } 
     
    private void Reports_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
    { 
          PopUpText.Text = "You Clicked Reports"; 
          myPopup.IsOpen = true; 
    } 

Running the Application
When you click different images you will be notified by the PopUp Control.

image3.gif

Figure 1.3 PopUp is displayed

That's it, we have successfully used the PopUp Control. Enjoy Coding.

 

 

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in