微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Silverlight应用程序填充浏览器窗口

我想要我的Silverlight应用程序来填充整个浏览器窗口.我将插件对象的宽度和高度设置为100%,并将我的LayoutRoot容器的高度和宽度设置为Auto,但仍然没有运气.有什么建议么?

<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:Silverlight ID="Silverlight1" runat="server" 
        Source="~/ClientBin/Client.xap"
        MinimumVersion="2.0.30818.0"
        AutoUpgrade="true"
        Height="100%" 
        Width="100%">
    </asp:Silverlight>
</form>

<UserControl 
    x:Class="Client.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Height="Auto"
    Width="Auto">
    <Grid 
        x:Name="LayoutRoot" 
        Background="#084E85"
        ShowGridLines="True">
        <Grid.ColumnDeFinitions>
            <ColumnDeFinition Width="280" />
            <ColumnDeFinition Width="Auto" />
        </Grid.ColumnDeFinitions>
        <Grid.RowDeFinitions>
            <RowDeFinition Height="80" />
            <RowDeFinition Height="Auto" />
            <RowDeFinition Height="600" />
        </Grid.RowDeFinitions>

        ...Remaining content here...
    </Grid>
</UserControl>

免责声明:我首先搜索一个答案,找到了this thread.但是,正如你可以看到我的代码不适合我的.

解决方法

首先,我不设置用户控件的高度/宽度.相反,我设置了DesignHeight和DesignWidth(在“ http://schemas.microsoft.com/expression/blend/2008”命名空间中),并将对齐方式设置为拉伸

<UserControl ... 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    d:DesignHeight="1050" d:DesignWidth="1680">

在我的Html中,我将Height和Width设置为100%

<div style="height: 100%; width: 100%; position: fixed;">
        <asp:Silverlight runat="server" Source="~/ClientBin/My.xap" ID="MyId" 
            Width="100%" Height="100%" />
</div>

在这一点上,一切都适用于我,让它占据整个窗口.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐