C# WP-XAML将网格覆盖在矩形上

C# WP-XAML将网格覆盖在矩形上,c#,windows-phone-7,xaml,C#,Windows Phone 7,Xaml,在我的Windows phone应用程序视图中有一个显示摄像头提要的,我正试图找出XAML代码,以便在提要上放置一个部分透明的图像 我有工作代码: <Grid x:Name="LayoutRoot"> <Rectangle x:Name="_previewRect" Margin="0" Height="800" Width="600"

在我的Windows phone应用程序视图中有一个显示摄像头提要的
,我正试图找出
XAML
代码,以便在提要上放置一个部分透明的图像

我有工作代码:

<Grid x:Name="LayoutRoot">

        <Rectangle x:Name="_previewRect" 
                   Margin="0" 
                   Height="800" 
                   Width="600" 
                   HorizontalAlignment="Center" 
                   VerticalAlignment="Center"
                   Tap="OnTapDown">

            <Rectangle.Fill>
                <VideoBrush x:Name="_previewVideo">
                    <VideoBrush.RelativeTransform>
                        <CompositeTransform  
                            x:Name="_previewTransform" CenterX=".5" CenterY=".5" />
                    </VideoBrush.RelativeTransform>
                </VideoBrush>
            </Rectangle.Fill>

       </Rectangle>

    </Grid>

它完美地显示了我的相机馈送(当然大部分代码都在codebehind中)

但现在我想添加一个图像作为覆盖。我试着加上:

<Grid.Background>
    <ImageBrush ImageSource="Images/Background/BackgroundBlurred.png" Stretch="UniformToFill" />
</Grid.Background>

元素的上面和下面,但没有这样的运气

有人知道我该怎么做吗?这似乎并不难,但我刚刚开始学习
XAML


谢谢

如果希望图像覆盖在视频馈送矩形上,则必须将其作为“layoutRoot”网格中的单独控件。只需将其直接放置在矩形顶部,并为其指定更高的值:



我理解您的逻辑,但我的图像仍然没有显示出来。甚至在ZAML预览中都没有。还有什么我可以尝试的吗?通过将图像代码粘贴到空网格中,确保您的图像确实存在。如果仍然没有显示,则说明您没有正确加载图像。此外,尝试使用填充的普通矩形作为覆盖,并确保正确显示。尝试几种不同的组合来缩小问题的范围。你也可以用最新的代码来更新你的问题,知道了吗!我从中引用图像的XAML位于子目录中,因此我忘记了图像路径中的前导“../”。非常感谢你的帮助!
<Grid x:Name="LayoutRoot">
    <Rectangle x:Name="_previewRect" 
               Margin="0" 
               Height="800" 
               Width="600" 
               HorizontalAlignment="Center" 
               VerticalAlignment="Center"
               Tap="OnTapDown"
               Canvas.ZIndex="1">
        <Rectangle.Fill>
            <VideoBrush x:Name="_previewVideo">
                <VideoBrush.RelativeTransform>
                    <CompositeTransform  
                        x:Name="_previewTransform" CenterX=".5" CenterY=".5" />
                </VideoBrush.RelativeTransform>
            </VideoBrush>
        </Rectangle.Fill>
    </Rectangle>

    <Image x:Name="myOverlayImage" Canvas.ZIndex="2">
        <!-- Your overlay is now a sibling of the video-feed Rectangle, but drawn on top of it -->
    </Image>
</Grid>