简体   繁体   English

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

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

I have a usercontrol that I am placing in a grid. 我有一个放置在网格中的用户控件。 Inside the grid I am also drawing lines. 在网格内部,我也在画线。 These lines appear above the usercontrol like they should. 这些行像应显示在usercontrol上方一样。

When the user clicks on my usercontrol, I am showing another part of the usercontrol, an xaml element (making it visible) and I need it to appear above the drawn lines. 当用户单击我的用户控件时,我正在显示用户控件的另一部分,一个xaml元素(使其可见),并且需要它出现在绘制的线条上方。

I've tried Canvas.ZIndex. 我已经尝试过Canvas.ZIndex。 That seems to only work with elements inside my usercontrol. 这似乎只适用于我的usercontrol内部的元素。 If I set the usercontrols ZIndex high, then it all appears above the lines. 如果我将用户控件ZIndex设置为高,则所有这些都显示在行上方。

Here is the Min working example: 这是Min的工作示例:

I need the Blue square to stay below the black line and the yellow ellipse to be above the black line. 我需要蓝色正方形保持在黑线下方,黄色椭圆保持在黑线上方。

--Main Page-- - 主页 -

<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--

<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>

Don't set a ZIndex on the control, just modify it for the sub controls. 不要在控件上设置ZIndex,只需对其子控件进行修改即可。

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

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

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

相关问题 Windows Phone 8.1 Silverlight和XAML - Windows Phone 8.1 Silverlight and XAML 在XAML中绑定UserControl的DataContext不起作用(Windows Phone) - Binding the DataContext of a UserControl in XAML is not working (Windows Phone) Windows Phone - 在UserControl xaml中使用DependencyProperty - Windows Phone - using DependencyProperty within UserControl xaml Windows Phone 7上的UserControl上的XAML中的自定义事件 - Custom events in XAML on my UserControl on Windows Phone 7 XAML绑定问题中的ImageSource Windows Phone - ImageSource in XAML binding issue Windows phone Windows Phone的Silverlight中的文本包装问题 - Text Wrapping issue in silverlight for Windows Phone Silverlight XAML布局问题 - Silverlight XAML layout issue Windows Phone 8,将DependencyProperty用于usercontrol,PropertyChangedCallback和CoerceValueCallback问题 - Windows Phone 8, use DependencyProperty for a usercontrol, PropertyChangedCallback and CoerceValueCallback issue 从Windows Phone 8.1将UserControl转换为通用应用程序10中的问题 - Issue in Convert UserControl from windows phone 8.1 to universal application 10 Windows Phone 10 Xaml ListView.ItemTemplate绑定用户控件对象属性 - Windows Phone 10 Xaml ListView.ItemTemplate binding usercontrol object property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM