Anyone who knows Silverlight is aware that a Silverlight application can toggle between browser embedded and full screen. In other words consume the entire desktop with your Silverlight application. But what if we want to go to full screen with one control inside your Silverlight application? Here's how.
I'll use the example of the ekleeman.silverlight.controls MediaPlayer.
First you need some properties to get the screen resolution and to set the ScaleTransform of your control:
private ScaleTransform SkinScale { get; set; }
private double BeforeFullScreenWidth { get; set; }
private double BeforeFullScreenHeight { get; set; }
Here is the SetScale method:
SkinScale is a reference to a ScaleTransform object in the MediaPlayer skin XAML.
Now we need two methods to set the control to full screen and set it back to browser embedded when escape is pressed.
BeforeFullScreenWidth and BeforFullScreenHeight are private properties that save the values during full screen mode.
And finally we wire up the FullScreenChanged event.
Application.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);
Then we add some event code to make the magic:
And finally the MouseLeftButtonDown event to go to full screen mode.
So there we have it. You can have controls inside your Silverlight applications toggle to and from full screen mode with a little bit of code.
Cheers!
-Eric