The ZIndex Property — At Last!


There are a handful of new features in Beta 2 and lots of performance tweaks and bug fixes.  My favorite new feature: the ZIndex property!  Hooray!  Anyone who has dabbled with WPF even remotely has requested this feature and now we have it — an attached property on every FrameworkElement!  And, of course, it is a DependencyProperty, so you can animate it. Here’s a simple code sample:


<Page xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” WindowTitle=”ZIndex Sample”>
  <Canvas>
    <Rectangle Canvas.ZIndex=”3″ Width=”100″ Height=”100″ Canvas.Top=”100″ Canvas.Left=”100″ Fill=”blue”/>
    <Rectangle Canvas.ZIndex=”1″ Width=”100″ Height=”100″ Canvas.Top=”150″ Canvas.Left=”150″ Fill=”yellow”/>
    <Rectangle Canvas.ZIndex=”2″ Width=”100″ Height=”100″ Canvas.Top=”200″ Canvas.Left=”200″ Fill=”green”/>


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


    <Rectangle Canvas.ZIndex=”1″ Width=”100″ Height=”100″ Canvas.Top=”300″ Canvas.Left=”200″ Fill=”green”/>
    <Rectangle Canvas.ZIndex=”3″ Width=”100″ Height=”100″ Canvas.Top=”350″ Canvas.Left=”150″ Fill=”yellow”/>
    <Rectangle Canvas.ZIndex=”2″ Width=”100″ Height=”100″ Canvas.Top=”400″ Canvas.Left=”100″ Fill=”blue”/>
  </Canvas>
</Page>


 

Comments (12)

  1. Erno says:

    Karsten, – could you provide a list of changes from the feb CTP to Beta 2?

    Thanks!

  2. karstenj says:

    The list is so short, in fact I think the only new API is the ZIndex property, and the breaking changes are so obscure, that we didn’t do one this time…

  3. Una&amp;nbsp;novit&#224;&amp;nbsp;di&amp;nbsp;interesse nella nuova&amp;nbsp;Beta2 di WinFX &#232; la propriet&#224; ZIndex di un&amp;nbsp;panel,&amp;nbsp;permette…

  4. Ok, so one of the things I hope to achieve with this blog is to share all of the little gems that I come…

  5. gbarnett says:

    In this post http://gbarnett.org/archive/2006/05/05/9.aspx&amp;nbsp;I demonstrated depths and how they are…

  6. Persone los pioneros non rabata. Great…

  7. In this post http://gbarnett.org/archive/2006/05/05/9.aspx I demonstrated depths and how they are rendered

  8. In this post http://gbarnett.org/archive/2006/05/05/9.aspx I demonstrated depths and how they are rendered

  9. Ok, so one of the things I hope to achieve with this blog is to share all of the little gems that I come