title: WPF Panel.ZIndex for child elements
body: <p>I'm developing a small visual designer and I need to implement a function of indexing elements. All elements have their own level of visibility depend on each other. I'm not using ZIndex for main elements so they are displayed as they are in visual tree. But all elements when they are in set index mode have a region with an index number. The problem is that these regions inherit zindex of their parents. I tried to set up for these regions zindex = 1000, but it didn't help. </p>
  
  <pre><code>&lt;ControlTemplate x:Key="IndexRegion" TargetType="ContentControl"&gt;
          &lt;Border&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;!--&lt;TextBlock Text="Индекс: "&gt;&lt;/TextBlock&gt;--&gt;
                  &lt;TextBlock Text="{Binding TabIndex}"&gt;&lt;/TextBlock&gt;
              &lt;/StackPanel&gt;
          &lt;/Border&gt;
      &lt;/ControlTemplate&gt;
  &lt;Style x:Key="IndexRegionStyle" TargetType="ContentControl"&gt;
          &lt;Setter Property="HorizontalAlignment" Value="Left"&gt;&lt;/Setter&gt;
          &lt;Setter Property="Margin" Value="1 -15 0 0"&gt;&lt;/Setter&gt;
          &lt;Setter Property="Visibility" Value="{Binding IsTabIndexVisible, Mode=OneWay, Converter={StaticResource VisibilityOfBool}}"&gt;&lt;/Setter&gt;
          &lt;Setter Property="Panel.ZIndex" Value="1000"&gt;&lt;/Setter&gt;
      &lt;/Style&gt;
  
  
  &lt;DataTemplate DataType="{x:Type viewModel:WizardFormTextFieldViewModel}"&gt;
    &lt;wfSurface:DesignSurfaceItemContainer Width="{Binding Width}" Height="{Binding Height}" ClipToBounds="False"&gt;
      &lt;Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch"&gt;
  
        &lt;ContentControl Style="{StaticResource IndexRegionStyle}" Template="{StaticResource IndexRegion}"&gt;
        &lt;/ContentControl&gt; --- this is an index region
  
        &lt;Border Style="{StaticResource WrongElement}"&gt;
          &lt;Border Style="{StaticResource TextFieldStyle}"&gt;                        
          &lt;/Border&gt;
        &lt;/Border&gt;
      &lt;/Grid&gt;
    &lt;/wfSurface:DesignSurfaceItemContainer&gt;           
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>How can I make all regions to be above all main elements?</p>
  
  <p>Thank you!</p>