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