在WPF中显示对网格中其他控件的控制

use*_*666 6 wpf layout overlay

我正在开发一个WPF应用程序.
主窗口的子控件包含在网格中.
底行包含状态栏.

应用程序必须通知用户.
我想以编程方式在主窗口右下角的用户控件中显示通知.
我希望通知用户控件显示在状态栏和上一行中的控件上.

如何显示对网格中包含的其他控件的控件?
任何帮助将不胜感激

Vis*_*hal 8

Grid有一个名为ZIndex的属性.看看这个例子:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="ZIndex Sample">
  <Grid>

    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <Rectangle Grid.Row="0" Grid.ZIndex="3" Fill="blue"/>
    <Rectangle Grid.Row="0" Grid.ZIndex="1" Fill="yellow"/>
    <Rectangle Grid.Row="0" Grid.ZIndex="2" Fill="green"/>

    <!-- Reverse the order to illustrate z-index property -->

    <Rectangle Grid.Row="1" Grid.ZIndex="1" Fill="green"/>
    <Rectangle Grid.Row="1" Grid.ZIndex="3" Fill="yellow"/>
    <Rectangle Grid.Row="1" Grid.ZIndex="2" Fill="blue"/>

  </Grid>
Run Code Online (Sandbox Code Playgroud)

如果未指定ZIndex,则面板的子项将按指定的顺序呈现(即最后一个在顶部).

  • ZIndex 实际上是 WPF 中 Panel 上的附加属性,也被其他重叠布局面板(如 Canvas)使用。 (2认同)

use*_*666 6

我已经解决了我的问题。
我修改了主窗口的 XAML 标记。
我已经在新网格的同一单元格中声明了通知用户控件和包含主窗口子控件的网格。

我在通知用户控件的开始标记中设置了一些属性:

  • Grid.ZIndex="1"
  • 水平对齐=“右”
  • 垂直对齐=“底部”
  • 边距="0 0 20 20"

当通知用户控件可见时:

  • 通知用户控件位于包含主窗口子控件的网格上
  • 通知用户控件位于主窗口的右下角