locked
Resizing Silverlight Application to Browser Window RRS feed

  • Question

  • Hi, its me again.

    Is there any simple way to scale/resize a silverlight 3 application, soit will fit every screen?

    I created a project, which has a solid width and height, and i want everythin to be smaller, so all the content should shrink by the same ratio. something like hitting ctrl++ oder crtl+-. but if i do so, i cannot controll the application any more.

    is there a way, please help!

    JR

    EDIT: I tried it with an image in HTML, there it works like:

    <img src="[imagename]" width=30% height=30%>

    but my app should keep the same aspectratio.

    Sunday, April 11, 2010 4:40 PM

Answers

  • You could try using the ViewBox control from the SL toolkit, you should be able to find it in the assets panel by typing "Viewbox".  This should contain your content you want resized.  This should help with the issue you are trying to solve.
    Tuesday, April 13, 2010 4:54 PM
    Moderator

All replies

  • I'm not 100% sure what you are asking, but you should be able to use a Scale Transform on any UI items you would like. You can find it under transforms in the property panel.

    If you want your UI to fill the SL window, remove the height/width from the user control in Blend.  You can set a design height/width by using the artboard adorners, so you can still work with the control.

    Monday, April 12, 2010 3:20 PM
    Moderator
  • well it is actually not what i want, but you gave me an idea, how i can do it...

    what i wanted to say, that i want my application to dynamicly fit any screen or browser window. my apps original size is about 1200 x 700 (something like that) and it will look great on big screens like 22" (1680x1050) or bigger, but on a netbook, you will hardly see anything. 

    but since u mentioned the transform button, i think of triggering a state, where the size is set, by the width of the window around. (as long as i can find a way to get information about the window with js or html). because if i can do so, i can create an "if" - "if else" thing, that triggers a storyboard or state with the transform values inside.

    it will be a whole bunch of work for me, because i am new to develloping, and the way might be pretty long and wrong, but ill give it a try.

     

    thanks for your help!

    JR

    PS: if anyone got me right by now and knows a better way - let me know!

     

    EDIT: if i am able to grab the broswer width value is it possible to dynamically change the <ScaleTransform ScaleX=""/> ? for example get the scalexvalue from the page.xaml.js file ? or does xaml not provide dynamic content like js does?

    as i said, im new here, and until now i was only using html, css for websites, and matlab, c++ for some developing...

    Monday, April 12, 2010 11:00 PM
  • it seen to be harder than i first thought!

    i cannot access the scaletransform values from the xaml.cs file. it tells me, scaletransfor is static and writeprotected. 

    on the other hand clientsize, which i found to be the right value to catch the windowsize is not allowed. so i actually dont know how to go on, since my programming seems to right (which does not often happen) but silverlight wont support my ideas, so i would have to change it to a real application, to be able to access everytrhing and continue , but that is not what i want.

    PS: Nembers arent even allowed, which i think is essential for programming... :(

    Tuesday, April 13, 2010 12:07 AM
  • You could try using the ViewBox control from the SL toolkit, you should be able to find it in the assets panel by typing "Viewbox".  This should contain your content you want resized.  This should help with the issue you are trying to solve.
    Tuesday, April 13, 2010 4:54 PM
    Moderator
  • thanks for this hint, it looks promissing... ill try it tomorrow and let you know.

    Tuesday, April 13, 2010 10:00 PM
  • Is there a ViewBox control in Expression Blend 2 as well? 
    Tuesday, April 20, 2010 12:59 PM
  • I'm not 100% sure, but it might be in one of the older versions of the SL toolkit for SL2:

    http://silverlight.codeplex.com/releases/view/24246

     

    Did you try searching in the asset panel for viewbox?

     

    Tuesday, April 20, 2010 3:36 PM
    Moderator
  •  

    I try searching in the asset panel for viewbox but Expression blend 3 in  asset panel viewbox control is not there .then how is  it

    Possible in Expression blend 3 ?

    Wednesday, February 9, 2011 5:24 AM
  • You may have to install the SL toolkit for SL3, and you may also have to add a reference to the right assembly to your project before it will show up.
    • Proposed as answer by khanvilkar Tuesday, March 8, 2011 6:19 AM
    Wednesday, February 9, 2011 2:20 PM
    Moderator
  • You may have to install the SL toolkit for SL3, and you may also have to add a reference to the right assembly to your project before it will show up.

    Thanks for your reply ,

    I got the viewbox in asset panel but my UI is not fit in window in any resolution. when i change my screen resolution 1440 X 900 still it change its width & height.

    even though i change the resolution of my screen it should fit the form inside the browser window.then how is it possiba ?

    Tuesday, March 8, 2011 6:34 AM