Silverlight 3 Quick Tip: Browser Zoom Support - DevCorner

Silverlight 3 Quick Tip: Browser Zoom Support

New version of Silverlight 3 supports zoom events from the hosting browser environment.

“Zoomed” event is the new event in Content static object, and the current browser’s zoom factor in “ZoomFactor” property of the Content object:

 

App.Current.Host.Content.Zoomed += (s, e) =>

{

    //Browser’s Zoom in:App.Current.Host.Content.ZoomFactor;

};

 

Enjoy,

Alex

Published Friday, July 10, 2009 10:23 AM by Alex Golesh

Comments

# Silverlight 3 Quick Tips

Pingback from  Silverlight 3 Quick Tips

Saturday, July 11, 2009 12:06 PM by Silverlight 3 Quick Tips

# Silverlight 3 Quick Tip: Browser Zoom Support – DevCorner | Xmas Tips

Pingback from  Silverlight 3 Quick Tip: Browser Zoom Support – DevCorner | Xmas Tips

# re: Silverlight 3 Quick Tip: Browser Zoom Support

Any advantage over Application.Current.Host.Content.Resized ?

Sunday, July 12, 2009 4:07 PM by Softlion

# re: Silverlight 3 Quick Tip: Browser Zoom Support

Softlion: Yes, the Application.Current.Host.Content.Resized will fire when you change browser zoom level, but the Application.Current.Host.Content.ActualHeight and App.Current.Host.Content.ActualWidth will not change... So the only way to know how you should scale your app is by checking App.Current.Host.Content.ZoomFactor. It could be checked from any of those two events, but Application.Current.Host.Content.Resized will fire every size change and App.Current.Host.Content.Zoomed only when browser zoom changed - then it is easier to handle content zoom scenarios with this event.

Thanks for the question - good one :)

Take care,

Alex

Sunday, July 12, 2009 4:18 PM by Alex Golesh

# re: Silverlight 3 Quick Tip: Browser Zoom Support

My silverlight app scales wonderfully in the browser--with no code on my part.  (Strangely, FireFox does a better job than IE in resizing of objects that are set to strech.)  

I'd like to run the app out-of-browser, but the OOB host does not seem to have a zoom function.  

I tried putting some buttons to zoom in/out into my app, but have not been able to replicate the functionality of App.Current.Host.Content.ZoomFactor as run within FireFox.  Controls which are set to stretch don't behave very well when you apply a ScaleTransform to the grid.

Any ideas how I could simulate App.Current.Host.Content.ZoomFactor in an OOB app?

Thanks Alex!

Tuesday, July 28, 2009 6:20 PM by gspence

# re: Silverlight 3 Quick Tip: Browser Zoom Support

gspence: No, you can't simulate it... Sorry.

But! You could subscribe to Resized event, and it will work even OOB. Hope this helps :)

App.Current.Host.Content.Resized += (s, e) =>

{

  ///

};

Alex

Wednesday, July 29, 2009 8:30 AM by Alex Golesh

# re: Silverlight 3 Quick Tip: Browser Zoom Support

Thank you Alex!

Wednesday, July 29, 2009 3:25 PM by gspence

# re: Silverlight 3 Quick Tip: Browser Zoom Support

Browser zoom support does not work when a ChildWindow is open. I hoped the bug will be fixed with the first silverlight update, but the update is aleready available and the bug still exists :(

Sunday, August 02, 2009 12:18 PM by mitkodi

# re: Silverlight 3 Quick Tip: Browser Zoom Support

mitkodi: Hi, you are not completely right. browser zoom event does occurs, even when ChildWindow opened. Yes, it has the issue is that is not accepting shortcuts (Ctrl+, Ctrl-), but from menu in FF and zoom controls in left bottom corner in IE it does work.

Regards,

Alex

Monday, August 03, 2009 7:56 AM by Alex Golesh

# re: Silverlight 3 Quick Tip: Browser Zoom Support

I’m sorry that I didn’t express myself clearly. I men that when we start a Silverlight application in a browser which zoom is already set to something different from 1, the content of the applications is  also scaled accordingly to browser's zoom factor, but when the user opens a ChildWindow the content is no longer zoomed until the user closes the ChildWindow.

Monday, August 03, 2009 10:59 AM by mitkodi

# re: Silverlight 3 Quick Tip: Browser Zoom Support

mitkodi: yes, this is because ChildWindow mimcs the behavior of modal dialog.

Alex

Monday, August 03, 2009 1:43 PM by Alex Golesh

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: