First time here? You are looking at the most recent posts. You may also want to check out older archives or the tag cloud. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS. Thank you for visiting! (hide this)

I've been working a bit more on Silverlight so here is another quick tip on it. This time it's about supporting the fullscreen mode of a Silverlight application.

ScottGu wrote about this topic back in early days of Silverlight 1.1 (Tip/Trick: Supporting Full Screen Mode with Silverlight) but I had a few problems implementing it: I tried to send my application in Full Screen mode handling an event raised by a control on my HTML page but the IsFullScreen property didn't want to go to true.

Let's first see how to send a Silverlight application in FullScreen mode:

private void OnFullScreenClicked(object sender, MouseEventArgs e)
{
    BrowserHost.IsFullScreen = true;
}

This code can be called from everywhere: Scott added is as handler for the MouseLeftButtonUp event of Silverlight canvas element:

Canvas fsBox = FindName("fullScreen") as Canvas;
fsBox.MouseLeftButtonUp += OnFullScreenClicked;

while I did the same, but with a HTML button:

HtmlDocument doc = HtmlPage.Document;
HtmlElement btnFs = doc.GetElementByID("btnFullScreen");
btnFs.AttachEvent("onclick", OnFullScreenClicked);

But I found out that my version didn't work: even after having set the true, the IsFullScreen property always stayed false.

After a bit of testing I found out that the Full Screen mode cannot be changed if the event that triggers it comes from the HTML/JavaScript side of the application.

Not sure if this a bug or a security feature, but if you find yourself in the need of send your Silverlight application to Full Screen, do it from a control inside the app.

Technorati Tag: ,
posted on Wednesday, February 6, 2008 12:22 PM

Comments on this entry:

# re: Sharing some Silverlight's bits: Full Screen Mode cannot be changed from HTML

Left by Ray Booysen at 2/6/2008 6:29 PM

Hey Simone

It is a security feature. It prevents dangerous scripts making the Silverlight application full screen.

From this link:

Full-screen mode message

A Silverlight plug-in can enable full-screen mode only in response to a set of user-initiated actions. These actions correspond to the MouseLeftButtonDown, MouseLeftButtonUp, KeyDown, and KeyUp events. If you try to set the FullScreen property to true in a Loaded event, the property setting is ignored. Limiting the actions that enable full-screen mode ensures that the user is always the initiator of full-screen mode behavior.

# re: Sharing some Silverlight's bits: Full Screen Mode cannot be changed from HTML

Left by Simone at 2/7/2008 2:23 AM

I've also discovered that in full screen mode the keyboard events are not raised (KeyUp and KeyDown).
This limits even more the feature of such a UI.
I guess only mouse is supported in fullscreen (but not the mouse wheel)
Maybe some other options can be found to limit security problems, maybe signing the application, but blocking keys events seems to strict.

Comments have been closed on this topic.