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

发布于 2024-09-26 11:20:30 字数 765 浏览 2 评论 0原文

如何将布局设置为 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>

How can I set a layout to have 100% width and 100% height?

I want my Silverlight application to stretch in the browser to fill all space.

I am using Expression Blend 4.

Here is my 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白龙吟 2024-10-03 11:20:30

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

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

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

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

希望这有帮助......

克里斯

Your application should do this automatically. The only reasons why it would not do so are:

  • You've constrained the size of the Silverlight object in the HTML page that hosts the application, or

  • You've explicitly set the width/height of the MainPage object in MainPage.xaml.

Setting the Background property of the MainPage object to a non-white colour should demonstrate this. If not, please include more details (including the XAML you are using).

Hope this helps...

Chris

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文