Silverlight Tips


Setting Default Browser From Within Visual Studio

From within VS you can specify which browser you want to launch on running your Silverlight application. Your default system browser is not affected by this setting.

To make this change –

1) right click on your startup web page and

2) choose Browse with… from the menu. You will get this –

Default Browser From Within The Visual Studio

Default Browser From Within The Visual Studio

3) select the browser you want to use and choose “Set as Default”.

 

Full Screen Mode Implementation

To have your application enter into full screen mode all you have to do is execute the following line of code –

“Application.Current.Host.Content.IsFullScreen = true”

Once in full screen Silverlight will briefly show the following message that will fade away in a few seconds.

  

Full screen message

Full screen message

 

 At this point the <ESC> key is reserved for exiting out of full screen mode. Of course, you can also exit manually by setting IsFullScreen = false.

 

Limitations/Restrictions to be aware of:

1) For security reasons, you cannot set the property IsFullScreen directly but rather only in the response to a user input event such as a button click.

     

2) To prevent password spoofing, only the following keyboard inputs are allowed while in full screen mode: 

  •   
  • space
  • arrow keys
  • tab
  • home
  • enter
  • end
  • pageup/pagedown

 

 Sample Source for Page.xaml.cs:

 

using System;
 using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes; 
namespace FullScreen
{    public partial class Page : UserControl    {
        public Page()        
           {  InitializeComponent();     }
         private void Button_Click(object sender, RoutedEventArgs e)
        {  ToggleFullScreen();   }
         private void ToggleFullScreen()
        {  Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;  }
    }
}

 

 

Page.xaml:

 


<UserControl x:Class="FullScreen.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Canvas>
        <Button Click="Button_Click" Content="Toggle Full Screen"></Button>
    </Canvas>
</UserControl>
 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s