Silverlight Quick Tip: How to resize window from Silverlight - DevCorner

Silverlight Quick Tip: How to resize window from Silverlight

One of my colleagues asked me if it is possible to resize the Browser Window from within Silverlight application.

Well, my answer was: “everything what is possible to do from JavaScript is possible to do from Silverlight”.

Here is sample code how to do it in case someone else is also looking for the solution:

if (HtmlPage.BrowserInformation.UserAgent.ToLower().IndexOf("chrome") < 0)
{
  HtmlPage.Window.Invoke("moveTo", new object[] { 100, 100 });
  HtmlPage.Window.Invoke("resizeTo", new object[] { 250, 250 });
}
//else
//  MessageBox.Show("Why bother? Chrome will not accept this anyway ;)");

* this will not work on Google Chrome probably because of some bug.

 

Enjoy,

Alex

Published Sunday, April 26, 2009 4:37 PM by Alex Golesh

Comments

# Silverlight Tip: Object Creation via Silverlight.js – IE8 & FireFox tweak

Yesterday, when I arrive to the office my colleague (same one from this post) waited for me at the entry

Friday, May 01, 2009 2:06 PM by DevCorner

Leave a Comment

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

Enter the numbers above: