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

时间:2010-10-09 21:32:59

标签: silverlight silverlight-4.0 expression-blend blend

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

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

我正在使用Expression Blend 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>

1 个答案:

答案 0 :(得分:2)

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

  • 您已经在承载应用程序的HTML页面中约束了Silverlight对象的大小,或者

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

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

希望这会有所帮助......

克里斯

相关问题