0

如何将布局设置为 100% 宽度和 100% 高度?

我希望我的 Silverlight 应用程序在浏览器中伸展以填充所有空间。

我正在使用表达式混合 4。

这是我的 XAML:

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="RichardKnopNew.MainPage"
    Width="960" Height="540">

    <Grid x:Name="LayoutRoot" Width="960" Height="540">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/bg.jpg"/>
        </Grid.Background>
        <Rectangle Fill="#FF252525" Stroke="Black" Opacity="0.7" RadiusX="10" RadiusY="10" Margin="25,115,335,25" StrokeThickness="0" Height="400"/>
    </Grid>
</UserControl>
4

1 回答 1

2

您的应用程序应该自动执行此操作。它不这样做的唯一原因是:

  • 您在托管应用程序的 HTML 页面中限制了 Silverlight 对象的大小,或者

  • 您已在 MainPage.xaml 中明确设置 MainPage 对象的宽度/高度。

将 MainPage 对象的 Background 属性设置为非白色应该可以证明这一点。如果不是,请提供更多详细信息(包括您正在使用的 XAML)。

希望这可以帮助...

克里斯

于 2010-10-10T06:09:15.750 回答