Silverlight 4.0 在另一个Usercontrol中添加Usercontrol以占用整个空间

Silverlight 4.0 在另一个Usercontrol中添加Usercontrol以占用整个空间,silverlight-4.0,Silverlight 4.0,我以编程方式添加的usercontrol没有显示 这是我的主页。xaml:- <UserControl x:Class="ScrollingEffect.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.mic

我以编程方式添加的usercontrol没有显示

这是我的主页。xaml:-

<UserControl x:Class="ScrollingEffect.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Canvas x:Name="LayoutRoot" Background="White">
        <Canvas x:Name="content" Height="Auto" Width="Auto"/>
        <Canvas Width="Auto">
            <StackPanel Height="27" Width="1400" Background="#B2000000"/>
        </Canvas>
    </Canvas>
</UserControl>
这是我的RedBack.xaml:-

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    x:Class="ScrollingEffect.RedBack"
    d:DesignWidth="640" d:DesignHeight="480">

    <Canvas x:Name="LayoutRoot">
        <Canvas.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="0.078"/>
                <GradientStop Color="Red" Offset="1"/>
            </LinearGradientBrush>
        </Canvas.Background>
    </Canvas>
</UserControl>

尝试将网格用作RedBack.xaml中的主布局容器,然后将画布放置在网格中

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    x:Class="ScrollingEffect.RedBack"
    d:DesignWidth="640" d:DesignHeight="480">

    <Canvas x:Name="LayoutRoot">
        <Canvas.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="0.078"/>
                <GradientStop Color="Red" Offset="1"/>
            </LinearGradientBrush>
        </Canvas.Background>
    </Canvas>
</UserControl>