Select to view content in your preferred language

Set Map Height/Width to Auto

664
1
09-10-2010 11:30 AM
WilliamKimrey
Emerging Contributor
Hello all,

In trying to get a Silverlight 4 application with printing, I've had to fiddle with my layout on the PrintPage Event.  The biggest issue being the map's width (800 seems to be the magic number to print on a 8.5x11 sheet of paper).  I have no issue shrinking it down (using a MaintainExtentBehavior to make sure all the grpahics stay on the page), but I do have a problem in expanding it back to full size.

Currently, I'm setting it back to a hard value of 1200, but this is no ideal since many of my users have different monitors and use different resolutions.  Plus, having a set number isn't friendly for resizing the browser.  I've seen where a FrameworkElement can have it's Height and Width set to "Double.NaN" in order to take up all available space and this does indeed work.  I use it for a DataGrid in the same application.  However, this does not work for the Map control.

Is there another way that I can get the desired result?  This is pretty much the only thing keeping the application from being finished.
0 Kudos
1 Reply
SanajyJadhav
Deactivated User
Assuming you have put your map on Canvas, you can catch the Size_Changed Event for the canvas.In it, you can try something like below;

MyMap.Width = this.Width;
MyMap.Height = this.Height;

Hope this helps,
Sanjay J.
0 Kudos