Full screen Silverlight

So you’d like your app to run full screen, don’t you? Are you ready to get your brain blown off? Then let’s get started with it.

First rule: you can only enter full screen as a result of a user initiated action. This is a security feature, and I don’t know the reason of it, but smarter guys will tell you if you ask them. So no full screen enters in Window_Loaded event handlers, but you can add a MouseLeftButtonUp handler to the same window, and add the following code to the event handler:

Application.Current.Host.Content.IsFullScreen = true;

Security bypassed, the user initiated the action (although totally unaware of it). You might think that you’re good to go from now on, your application running full screen, everybody is happy. Sadly, there’s a little quirk here: you won’t get full keyboard support running full screen.

I was a little unspecific about what is full keyboard support. Well, you can rest assured that you can’t type in anything, but you can move around with arrows. Nice, isn’t it? Before you ask, no there’s no way to code this around.

From version 4, we have a solution to your problem. Setting the Application.Current.MainWindow.WindowState property to Maximized, you can have a maximized window on startup. You don’t even need the user to initiate an action for you, it just works. The code for the lazy ones:

Application.Current.MainWindow.WindowState = WindowState.Maximized;

It’s not full screen, just a plain old maximized window, but it did the trick for me.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s