如何正确设置Silverlight UserControl的高度?

时间:2009-01-06 21:08:57

标签: silverlight

我无法让我的silverlight控件高于600.请参阅下面的代码重现此行为。请注意,色带在exaclty 600停止。任何人都可以告诉我如何让这个例子显示网格中的所有行?

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/IT.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
            </div>
    </form>
</body>
</html>

<UserControl xmlns:my1="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" x:Class="IT.Test"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="1225">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions >
            <RowDefinition Height="175"/>
            <RowDefinition  Height="175"/>
            <RowDefinition  Height="175"/>
            <RowDefinition  Height="175"/>
            <RowDefinition  Height="175"/>
            <RowDefinition Height="175" />
            <RowDefinition Height="175" />
        </Grid.RowDefinitions>

        <Rectangle Grid.Row="0" Fill="Green"/>
        <Rectangle Grid.Row="1" Fill="Red" />
        <Rectangle Grid.Row="2" Fill="Blue" />
        <Rectangle Grid.Row="3" Fill="Orange"/>
        <Rectangle Grid.Row="4" Fill="Yellow" />
        <Rectangle Grid.Row="5" Fill="Black" />
        <Rectangle Grid.Row="6" Fill="Aqua"/>

    </Grid>

1 个答案:

答案 0 :(得分:0)

我将网格的背景设置为灰色(背景=“灰色”),并将所有行高设置为50,以查看发生了什么。我认为你的UserControl比浏览器的视口高,但由于它是空的,滚动条没有显示出来。所以我在底部有一个灰色的带子,一直到那个页面的底部。

编辑:如果您想要一个占用整个视口的UserControl,请从UserControl标记中删除Width和Height。