silverlight - 在页面中央制作 silverlight 对象

标签 silverlight

当我在 Visual Studio 中创建一个 Silverlight 项目,然后构建它时,VS 会弹出一个页面,其中包含我刚刚制作的 silverlight。但是那个 silverlight 对象总是在左上角,有什么办法可以使它在页面的水平中心?

最好的问候,

最佳答案

通常,插件内容在 HTML 页面其余部分中的定位是 HTML/CSS 而非 Silverlight 需要解决的问题。 (如果您想要寻找 CSS 解决方案,将视口(viewport)中的任何 HTML 元素居中,然后将其应用于托管控件的 .aspx 或 .htm 中的对象标记)。

不过,我猜您的页面中没有任何其他内容,该页面仅用于承载 silverlight 内容。在这种情况下,让 Silverlight 内容占据整个页面可能会更好。默认的 .aspx 和 .htm 测试页面旨在允许插件执行此操作,您只需从 UserControl< 移动 WidthHeight 属性 到内部“LayoutRoot”元素并将“LayoutRoot”设置为具有“Center”Horizo​​ntalAlignmentVerticalAlignment

换句话说:-

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

对此:-

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

关于silverlight - 在页面中央制作 silverlight 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2498701/

相关文章:

flash - 从 WebApp 与本地 PC 交互

c# - 扩展方法的问题

silverlight - Silverlight View通过MEF将DependencyProperty导出到ViewModel

silverlight - Silverlight 中 Canvas 内的动态剪切宽度

c# - 如何在 C# 中找到 Windows Phone7 应用程序的应用程序 contentIdentifier?

wpf - 在 Silverlight 中的 ContentPresenter 中将样式应用于 TextBlocks

silverlight - 将 silverlight 组合框绑定(bind)到另一个组合框的结果

c# - 调用异步 Web 方法完成后如何导航?

silverlight - 如何在 Silverlight 4 应用程序中禁用验证?

silverlight - 使用命名空间 Silverlight/XAML 的具体示例有哪些?