繁体   English   中英

Xaml(Windows Phone 8和Silverlight)用户控件堆叠问题

[英]Xaml (Windows Phone 8 & Silverlight) usercontrol stacking issue

我有一个放置在网格中的用户控件。 在网格内部,我也在画线。 这些行像应显示在usercontrol上方一样。

当用户单击我的用户控件时,我正在显示用户控件的另一部分,一个xaml元素(使其可见),并且需要它出现在绘制的线条上方。

我已经尝试过Canvas.ZIndex。 这似乎只适用于我的usercontrol内部的元素。 如果我将用户控件ZIndex设置为高,则所有这些都显示在行上方。

这是Min的工作示例:

我需要蓝色正方形保持在黑线下方,黄色椭圆保持在黑线上方。

- 主页 -

<UserControl xmlns:SWE_UserControlOverlap="clr-namespace:SWE_UserControlOverlap"  x:Class="SWE_UserControlOverlap.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">

    <Grid x:Name="LayoutRoot" Background="White">
        <SWE_UserControlOverlap:SWE />
        <Line Stroke="Black" StrokeThickness="10" Stretch="Fill" X1="0" Y1="0" X2="1" Y2="1"></Line>
    </Grid>
</UserControl>

--UserControl--

<UserControl x:Class="SWE_UserControlOverlap.SWE"
    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">

    <Grid x:Name="LayoutRoot" Background="White">
        <Rectangle Fill="Blue" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp_1"></Rectangle>
        <Ellipse Margin="100" Fill="Yellow" ></Ellipse>
    </Grid>
</UserControl>

不要在控件上设置ZIndex,只需对其子控件进行修改即可。

<Line Canvas.ZIndex="1" />
<Rectangle Canvas.ZIndex="0" />
<Ellipse Canvas.ZIndex="2" />

正如我在网络上的各个位置所发现的那样-这是不可能的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM