views:

102

answers:

2

Hi all,

In a Silverlight 4 out of browser app (oob) is there any way to programatically move the main window after the application start-up event.

The reason / Use case: A user selects an option on a silverlight desktop gadget app, the apps window grows to accomodate extra details. If the app started very near the right of the screen the details are obscured/ fall off the edge of the screen and the user needs to drag the window to the left. When the window returns to its smaller state it is now positioned to far left so the user needs to drag the window right again. It would be convention for the app to move itself back and forth automatically to accomodate the details.

Thanks.

A: 

I will leave the answer below to show my shame... sorry I did not read the question properly.

If you mean the position within the web page, yes you can.

Silverlight can execute Javascript on the hosting page to change attributes (including the size or position of the Silverlight plugin itself).

I have used this feature to resize a Silverlight 3 application to fit its content, enabling use of the browser scrollbars to move down a large app (not needed nowadays with full mousewheel support, but the principle is the same).

Enough already
It's an Out Of Browser application - so there's no web page.
ChrisF
Whoops... no more questions near midnight for me... I have seen NOOB so many times today I am OOB blind :)
Enough already
A: 

Avida - yes you can move the MainWindow using Top/Left properties as long as WindowsStartupPosition is Manual

Tim Heuer
Hi Tim - its no problem relocating a window to its previous position on startup, but after that the Left/Top properties seem to be disabled, so the use case above won't work.
David
Well, I disagree. It _is_ a problem if you want to do it cleanly. I could not find any way to restore the Saved Position without seeing the Window jump from its initial default Position to the Restored Position. If anyone knows a way to do it without the jump - let me know :)
Oliver Weichhold