title: Silverlight setting ZIndex of UserControl
body: <p>How do I set the ZIndex of a UserControl?
  I have tried</p>
  
  <pre><code>Canvas.SetZIndex((Tile)sender, 99);
  ((Tile)sender).SetValue(Canvas.ZIndexProperty, 99);
  </code></pre>
  
  <p>Tile is the name of my UserControl
  I have a Rectangle inside the UserControl that is what actually appears on the screen.
  I have also tried</p>
  
  <pre><code>Canvas.SetZIndex(((Tile)sender).rect, 99);
  ((Tile)sender).rect.SetValue(Canvas.ZIndexProperty, 99);
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Here is what the XAML for my UserControl</p>
  
  <pre><code>&lt;UserControl x:Class="Carcassonne.Tile"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      d:DesignHeight="76" d:DesignWidth="76"&gt;
  
      &lt;Canvas x:Name="LayoutRoot" Background="Transparent"&gt;
          &lt;Rectangle x:Name="rect" 
                     Width="76" Height="76"
                     HorizontalAlignment="Left"&gt;
              &lt;Rectangle.Fill&gt;
                  &lt;ImageBrush x:Name="tileImage"&gt;
                      &lt;ImageBrush.RelativeTransform&gt;
                          &lt;RotateTransform x:Name="rotation" CenterX="0.5" CenterY="0.5" Angle="0" /&gt;
                      &lt;/ImageBrush.RelativeTransform&gt;
                  &lt;/ImageBrush&gt;
              &lt;/Rectangle.Fill&gt;
          &lt;/Rectangle&gt;
      &lt;/Canvas&gt;
  &lt;/UserControl&gt;
  </code></pre>