如何在Silverlight中的Frame中添加多个控件

时间:2012-11-28 09:05:54

标签: c# silverlight silverlight-5.0

我是银光的新手。我必须在导航框架中添加多个控件。当我这样做时,我会收到错误。

<Navigation:Frame Name="ContentFrame" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,55,12,12" BorderThickness="1" BorderBrush="Black" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="5">
            <TextBlock Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="9,129,0,0" Name="textBlock2" Text="UserName:" VerticalAlignment="Top" />
            <TextBlock Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="12,22,0,0" Name="textBlock3" Text="Password:" VerticalAlignment="Top" Grid.Row="1" />
        </Navigation:Frame>

错误属性“内容”不能多次设置。哪里我错了。怎么做到这一点?

1 个答案:

答案 0 :(得分:2)

FrameContentControl,这意味着它只能有一个孩子。您需要添加一个能够容纳多个子项的子控件。试试Grid例如:

<Navigation:Frame >
   <Grid>
        <TextBlock Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="9,129,0,0" Name="textBlock2" Text="UserName:" VerticalAlignment="Top" />
        <TextBlock Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="12,22,0,0" Name="textBlock3" Text="Password:" VerticalAlignment="Top" Grid.Row="1" />
   </Grid>
</Navigation:Frame>