none
window.showmodaldialog prevents sliverlight app from resizing

    Question

  • I have a Silverlight application which is being called from an asp page via window.showmodaldialog.  I need to use showmodaldialog as the other window needs to remain.  The sliverlight app is loaded but the resize functionality of the silverlight app has been removed.  If I resize the window via the bottom right hand corner the silverlight app doesn't resize.

    If I don't use showmodaldialog it does resize (window.open).

    Example HTML

     <html>
    <body onload="var _Width = screen.width - 50; var _Height = screen.height - 50; var _PopupArgs = 'resizable:yes; scroll:yes; status:no; dialogHeight:' + _Height + 'px; dialogWidth:' + _Width + 'px;dialogTop:50px;dialogLeft:50px;';window.showModalDialog('http://mysilverlightapp.com','',_PopupArgs);">
    Testa

    </Body>
    </html>

    Tuesday, April 05, 2011 6:05 AM

Answers

  • Hi, I have a solution to the problem which hopefully will work for you.

    I had a thought (triggered by the comment regarding it being a problem with showmodalDialog not Silverlight) which was that it's something to do with the <!DOCTYPE> tag that's automatically inserted at the top of the page when VS create's the hosting page for the Silverlight control.

    Basically if remove this tag it works as expected. Removing the doctype may cause you other issues (I haven't discovered any) but for me it solves the problem  - I'm not mixing silverlight and html on the page, the content is all Silverlight.

    Hope this solves your problem too...

     

     

    Friday, April 08, 2011 5:25 AM

All replies

  • I've also got exactly the same problem. I'm new to Silverlight and thought it must be something I'm doing wrong, particularly as there seems to be nothing on the web about this -  your post is the first I've come across.

    If you attach to the resize event (App.Current.Host.Content.Resized) it only fires when the app loads and never again. I'm wondering whether to try a workaround where by you attach to the onresize event in javascript and call through to the silverlight app to set its width and height from the javascript function.

    I'll let you know if this works, but in the meantime lets hope someone else posts an answer to this...

     

     

    Wednesday, April 06, 2011 8:49 PM
  • It's strange.  If I use the bottom right hand corner of the window the re-size the silverlight app doesn't resize.  If I click on the bottom bar part of the window and move it up (vertically) it resizes that portion of the SL app.   If I click on the right hand side bar and move it to the left it doesn't resize the SL App.  Any ideas?

    Thursday, April 07, 2011 9:50 AM
  • Hi,

      If I resize the window via the bottom right hand corner the silverlight app doesn't resize.

    This behavior not only occurs in Silverlight but also occurs in other Content. you can try to open a nomal site via window.showmodaldialog to check this out.

    So this is the window.showmodaldialog default behavior not Silverlight.

     

    I need to use showmodaldialog as the other window needs to remain.

    For this, you don't need to use window.showmodaldialog, you can use a IFrame to load the Silverlight content you need.

     

    Regards

    Friday, April 08, 2011 4:25 AM
  • Hi, I have a solution to the problem which hopefully will work for you.

    I had a thought (triggered by the comment regarding it being a problem with showmodalDialog not Silverlight) which was that it's something to do with the <!DOCTYPE> tag that's automatically inserted at the top of the page when VS create's the hosting page for the Silverlight control.

    Basically if remove this tag it works as expected. Removing the doctype may cause you other issues (I haven't discovered any) but for me it solves the problem  - I'm not mixing silverlight and html on the page, the content is all Silverlight.

    Hope this solves your problem too...

     

     

    Friday, April 08, 2011 5:25 AM
  • Hi,

    That's great. It's a workaround.

    Thanks for sharing.

     

    Regards

    Friday, April 08, 2011 5:33 AM
  • Hi,

    The <!DOCTYPE> work around has worked a treat and the app is resizing fine now.  I'm only using IE and don't need cross broswer support so hopefully I won't come across any issues.

    Many Thanks.....

    Friday, April 08, 2011 5:48 AM
  • Yes, I only need to support IE too, but it was cross browser support that I thought might be an issues for others...

    Thanks to Daoping Liu for pointing out that it might be showModalDialog that was the problem not Silverlight itself...

     

    Friday, April 08, 2011 5:56 AM