Silverlight has great full-screen support, and it is a simple matter to switch to full screen by setting the IsFullScreen property of the content object as follows. Note for security reasons this can only be done in response to user input; note also that this code has changed from version 1.1 alpha
//get the plugin content object
System.Windows.Interop.Content content = Application.Current.Host.Content;
public Page()
{
InitializeComponent();
// wire up key down and full screen changed events
this.KeyDown += new KeyEventHandler(Page_KeyDown);
content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);
}
void Page_KeyDown(object sender, KeyEventArgs e)
{
// go full screen when F is pressed (esc will take us out of full screen)
if (e.Key == Key.F )
{
content.IsFullScreen = true;
}
}
However Silverlight does not automatically scale your content automatically, so by default you will typically be left with a lot of empty space. It turns out though that this is pretty easy to fix - we can simply hook up the FullScreenChanged event, work out the change in size and then apply a ScaleTransform to our control:
void Content_FullScreenChanged(object sender, EventArgs e)
{
//scale content if we are in full screen.
if (content.IsFullScreen)
{
double heightRatio = content.ActualHeight / this.Height;
double widthRatio = content.ActualWidth / this.Width;
ScaleTransform scale = new ScaleTransform();
scale.ScaleX = widthRatio;
scale.ScaleY = heightRatio;
this.RenderTransform = scale;
}
else
{
this.RenderTransform = null;
}
}
Cheers
Ian