Skip to main content

Microsoft Silverlight

Answered Question Scale when fullscreen and browser resizeRSS Feed

(0)

Qbus
Qbus

Member

Member

607 points

269 Posts

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

bartczernicki
bartczer...

Contributor

Contributor

4172 points

730 Posts

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).

James_Hardaker
James_Ha...

Member

Member

56 points

22 Posts

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

Qbus
Qbus

Member

Member

607 points

269 Posts

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

Cabral
Cabral

Member

Member

64 points

12 Posts

Answered Question

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.

kwatts
kwatts

Contributor

Contributor

2129 points

436 Posts

Answered Question

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!

Qbus
Qbus

Member

Member

607 points

269 Posts

Answered Question

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

kwatts
kwatts

Contributor

Contributor

2129 points

436 Posts

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!

Qbus
Qbus

Member

Member

607 points

269 Posts

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
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities