开发者

Make silverlight object in the center of page

When I create a Silverlight project in the Visual Studio, then build it, the VS would popup a page with the silverlight that I just made.But that silverlight object always on the left-up开发者_运维技巧 corner, is there any way to make it in the horizontal center of the page?

Best Regards,


Ordinarily the positioning of the plugin content within the rest of the HTML page is a problem for the HTML/CSS to solve not the Silverlight. (If you want that look for CSS solutions that center any HTML element in the Viewport and then apply it to the object tag in the .aspx or .htm hosting your control).

However I'm going to guess you don't have any other content in the page, the page exists only to host the silverlight content. In this case it may be better to let the Silverlight content occupy the entire page. The default .aspx and .htm test pages are designed to allow the plugin to do that, you just need to move the Width and Height properties from the UserControl to the inner "LayoutRoot" element and set the "LayoutRoot" to have "Center" HorizontalAlignment and VerticalAlignment.

In other words from this:-

<UserControl xmlns=".... blah...."
  Width="600" Height="400">
  <Grid x:Name="LayoutRoot">
    <!-- Content here --?
  </Grid>
</UserControl>

to this:-

<UserControl xmlns=".... blah....">
  <Grid x:Name="LayoutRoot" Width="600" Height="400"
    HorizontalAlignment="Center" VerticalAlignment="Center">
    <!-- Content here --?
  </Grid>
</UserControl>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜