PDA

View Full Version : Is there a way to scale an object proportionately in blend/silverlight 2?



fooj
December 21st, 2008, 04:10 PM
I have a Silverlight 2 application that I'm laying out using Blend. There are five elements on the page. When I remove one of the elements (in this example, the yellow rectangle) I want the other elements to fill the page as follows: red rectangle to scale proportionately to fill 50% of the layout pushing both light blue and dark blue rectangles down, and green rectangle to fill 50% of the layout (not proportionately). Light blue and dark blue rectangles do not change in height but can change in width.

Here is a graphic that illustrates what I am trying to accomplish: proportionately scaling layout (http://cid-84a891c2054d89fd.skydrive.live.com/self.aspx/Public/proportionate.png)

I have not been able to find any properties or controls in Blend that allow me to 'lock' the proportions of an object. Am I just missing it? Any help or insight provided is greatly appreciated!

kirupa
December 21st, 2008, 10:47 PM
Hi Fooj!
That is possible using the Grid layout panel and rows/columns. The following page should provide guidance: http://expression.microsoft.com/en-us/library/cc295203.aspx

I have attached a project that does exactly what your example shows.

Hope this helps :)

Cheers!
Kirupa :cowboy:

fooj
December 22nd, 2008, 05:55 AM
Thank you for responding, Kirupa!

Unfortunately, your example does not do what I need. The red rectangle needs to maintain it's ratio (4:3 video for example). I've spend quite a while investigating the various layout controls including the grid panel. If you have any other ideas, I'm all ears!

All the best,
fooj

kirupa
December 24th, 2008, 08:23 PM
Ah, you are right. I don't have a good example for that. One solution that may work is listening to the Resize event on the UserControl and programmatically enforcing the layout. That isn't a scalable solution, for you pretty much have to ensure that all of the other elements are resized and moved around.

I will fiddle with this over the holidays, for I am now curious how to best achieve this.

:)