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

Kev*_*ock 14 browser size silverlight

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

<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>
Run Code Online (Sandbox Code Playgroud)

免责声明:我首先搜索了一个答案,找到了这个帖子.但是,您可以通过我的代码看到这对我不起作用.

Bri*_*sio 18

首先,我没有在用户控件中设置高度/宽度.相反,我设置了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">
Run Code Online (Sandbox Code Playgroud)

在我的Html中,我将高度和宽度设置为100%,就像这样......

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

那时,一切都适合我让它占据整个窗口.