1

我正在开发一个小型视觉设计器,我需要实现索引元素的功能。所有元素都有自己的可见性级别,相互依赖。我没有将 ZIndex 用于主要元素,因此它们显示为在可视树中。但是所有处于设置索引模式的元素都有一个带有索引号的区域。问题是这些区域继承了它们父母的 zindex。我尝试为这些区域设置 zindex = 1000,但没有帮助。

<ControlTemplate x:Key="IndexRegion" TargetType="ContentControl">
        <Border>
            <StackPanel Orientation="Horizontal">
                <!--<TextBlock Text="Индекс: "></TextBlock>-->
                <TextBlock Text="{Binding TabIndex}"></TextBlock>
            </StackPanel>
        </Border>
    </ControlTemplate>
<Style x:Key="IndexRegionStyle" TargetType="ContentControl">
        <Setter Property="HorizontalAlignment" Value="Left"></Setter>
        <Setter Property="Margin" Value="1 -15 0 0"></Setter>
        <Setter Property="Visibility" Value="{Binding IsTabIndexVisible, Mode=OneWay, Converter={StaticResource VisibilityOfBool}}"></Setter>
        <Setter Property="Panel.ZIndex" Value="1000"></Setter>
    </Style>


<DataTemplate DataType="{x:Type viewModel:WizardFormTextFieldViewModel}">
  <wfSurface:DesignSurfaceItemContainer Width="{Binding Width}" Height="{Binding Height}" ClipToBounds="False">
    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">

      <ContentControl Style="{StaticResource IndexRegionStyle}" Template="{StaticResource IndexRegion}">
      </ContentControl> --- this is an index region

      <Border Style="{StaticResource WrongElement}">
        <Border Style="{StaticResource TextFieldStyle}">                        
        </Border>
      </Border>
    </Grid>
  </wfSurface:DesignSurfaceItemContainer>           
</DataTemplate>

我怎样才能使所有区域都高于所有主要元素?

谢谢!

4

1 回答 1

3

ZIndex 是一个索引,用于组织兄弟姐妹(同一容器的子控件)的 z 顺序

If you want elements to be on top of 'everything' you need to add a new container that is on top of everything. You cannot specify this from a lower level such as this Template. The UI remains a hierarchy, you can't break that as far as I know.

于 2012-05-12T06:17:11.890 回答