title: WPF how to determine z order for panel containing visualcollection that is an itemshost?
body: <p>I am trying to understand how rendering order works, and as I understand it the rendering engine renders things in order as it progresses the visual tree.</p>
  
  <p>I currently have a Panel that contains a</p>
  
  <pre><code>VisualCollection visuals;
  </code></pre>
  
  <p>and overrides the getvisual child function.</p>
  
  <pre><code>protected override Visual GetVisualChild(int index)
  {
    return visuals[index];
  }
  protected override int VisualChildrenCount
  {
    get
    {
      return visuals.Count;
    }
  }
  </code></pre>
  
  <p>However, I am wondering how to manage ZIndex of the items that the panel will be hosting relative to the visual collection.</p>
  
  <p>If there were no visual collection, I could just manage the panel's child controls by setting the Panel.ZIndex on the panel's child controls and on the ItemsControl's Item Style.</p>
  
  <p>And as I understand it, I can control the rendering order of the items in the visualcollection by changing the visual collection's order. However, How do I do both at the same time?</p>