Page view counter
Scale when fullscreen and browser resize Subscribe to this thread
Last post 10-29-2008 1:03 PM by Qbus. 8 replies.
Sort Posts:
10-27-2008 4:19 PM
Scale when fullscreen and browser resize

Hi

I have searched alot now I think, but can't seem to find any good samples in Silverlight 2.0 (final release).

What I am looking for is actually two things.

First I want to see some code that will put my application into fullscreen mode (this part is easy enough) and then scale my application to look the same in fullscreen mode (this is the hard part).

Secondly I want to see some code/samples that will make my hole application always fill the browser window 100% both in width and height. 

Any good links to samples here, or just plain code would be help full.

Thanks in advance,

Qbus

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net

Qbus

Loading...
Joined on 01-14-2006
Denmark
Posts 214
10-27-2008 4:52 PM
Re: Scale when fullscreen and browser resize

Check this site out its pretty cool how its laid out and its really simple.  The controls stay in the middle and if you stretch the screen it always fills it up:

http://silverlightdesign.nl/

So how do you do that?  Well first you need to set the background of your controls that you want to take up the width to stretch.  Notice the vertical gradients stretch very nicely like that ( <Rectangle Height="120" VerticalAlignment="Bottom" Stroke="#00000000" Stretch="Fill"> )

Second, you want to make sure you keep the elements in the middle so that they are not fixed.  You don't want your elements to left of the screen if the person adjusts the size of the window.  For example, I used a stackpanel and keep my buttons alaways in the center of the screen and on the bottom doing this ( HorizontalAlignment="Center" VerticalAlignment="Bottom")

Don't use fixed width stuff other than the granular/leaf level controls.  That will get you in trouble quick.  For example, you can have a dialog box with a ton of controls laid out however you want..but lay that dialog box in the center and not position it with fixed points (i.e. Canvas.Left="100).

Please "Mark as Answer" if any of my content helped
Bart Czernicki
http://www.silverlighthack.com | http://www.twitter.com/bartczernicki

bartczernicki

Loading...
Joined on 04-30-2008
New Jersey, USA
Posts 634
10-28-2008 10:22 AM
Re: Scale when fullscreen and browser resize

get the original size of your screen.

Perhaps its 800*600.

 Use a scale transform on your panel.

Get the fullscreen size e.g. 1680 * 1050.

ScaleX = 1680 / 800

ScaleY = 1050 / 600

i cant rembmer where centerX and CenterY goes but Im sure you can figure it out

James_Hardaker

Loading...
Joined on 08-27-2008
Posts 22
10-28-2008 10:39 AM
Re: Re: Scale when fullscreen and browser resize

Thanks both of you, I will take a look at it and return when ever I figure it out :)

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net

Qbus

Loading...
Joined on 01-14-2006
Denmark
Posts 214
10-28-2008 2:05 PM
Marked as Answer
Re: Scale when fullscreen and browser resize

First:

This code set your app full screen mode:

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

Second:

To set the scale of your application into full screen mode you need to set Width and Height value of your LayoutRoot to "Auto" and HorizontalAlignment and VerticalAlignment set value to "Stretch" this will resize your application or you can do it by events: Content_FullScreenChanged or Content_Resized.

I think the application cant start with fullscreen mode this can be set by click of button or any events, but not Load event.

Thanks.

Cabral

Loading...
Joined on 10-22-2008
Posts 12
10-28-2008 3:36 PM
Marked as Answer
Re: Scale when fullscreen and browser resize

Here's an example of a Silverlight application (Digital Logic Simulator) that scales on full-screen resize:

http://kenwatts.blogspot.com/2008/08/digital-logic-simulator-in-silverlight.html

I have made the source available at CodePlex, you should see a link on that page.

Also, here's an example of a Silverlight application that resizes in the browser as the size of the browser changes:

http://gearworld.dyndns.org:8082/devpreview/ 

I hope that this helps!

-Ken
 


http://kenwatts.blogspot.com/


Please select "Mark as Answer" for posts that are helpful. Thanks!

kwatts

Loading...
Joined on 08-18-2008
Belchertown, MA
Posts 436
10-28-2008 5:13 PM
Marked as Answer
Re: Re: Scale when fullscreen and browser resize

Thanks for the replies. I have made this little sample project be the answers in this post, maybe good for others with same problems as me.

http://laumania.net/post/Fullscreen-samples-for-Silverlight.aspx

Thanks for your answers.

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net

Qbus

Loading...
Joined on 01-14-2006
Denmark
Posts 214
10-29-2008 10:57 AM
Re: Re: Scale when fullscreen and browser resize

Looks good, but I think that it would be nice if you hosted working versions of your project so that we can see the code in action without having to build it.  Also, it would be nice if the code was available for browsing on-line so that we don't have to download it separtely.

-Ken


http://kenwatts.blogspot.com/


Please select "Mark as Answer" for posts that are helpful. Thanks!

kwatts

Loading...
Joined on 08-18-2008
Belchertown, MA
Posts 436
10-29-2008 1:03 PM
Re: Re: Re: Scale when fullscreen and browser resize

Great idea, I will look into that and return here.

Smile

--------------------------
Please mark the post as answered if this answers your question
http://www.laumania.net

Qbus

Loading...
Joined on 01-14-2006
Denmark
Posts 214
Microsoft Communities