Skip to main content

Microsoft Silverlight

Answered Question Center Silverlight on browser page (like this forum)RSS Feed

(0)

terryl
terryl

Member

Member

29 points

29 Posts

Center Silverlight on browser page (like this forum)

Hi:

 I've read some of the posts on howto do this.  Set width = 100% in the CSS or place content in a grid with 3 columns, the middle the width I want and the first and third = *.  Those don't work for me.  My UserControl remains on the left hand side of the browser window no matter how wide I make it.  Did these techniques quit working in SL3 or am I doing something wrong?  Can someone give me a code example?

 Thanks,

 Terry

Sledge70
Sledge70

Contributor

Contributor

5962 points

1,047 Posts

Re: Center Silverlight on browser page (like this forum)

Have you tried setting the Vertical and Horizontal Alignment of your root control to stretched?

Also, you'll need to remove Width and Height on the root or have them set to Auto.

______________________________________________________
Please mark replies as answers if they answered your question...

Flexman on Silverlight

terryl
terryl

Member

Member

29 points

29 Posts

Answered Question

Re: Center Silverlight on browser page (like this forum)

HorizontalAlignment="Stretch" fixed it.  Thanks!

 I also discovered I could do the following in my Loaded event:

int screenWidth = Int32.Parse( System.Windows.Browser.HtmlPage.Window.Eval( "screen.width" ).ToString() );
BG_Image.Width = screenWidth;

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities