title: Silverlight popup ActualSize
body: <p>In Silverlight 3, I am trying to create a pop up menu for navigation.  I am using a HyperlinkButton as a trigger, which when moused over displays a Popup containing more HyperlinkButtons.  The root node is right aligned and I want the sub-menu to appear to the left.  My problem is that I am trying to position the popup using its ActualWidth property, but this value appears fixed at the size of the root element (which contains the trigger and the popup), so if the popup is narrower it leaves an unsightly gap and if wider it overwrites the trigger.</p>
  
  <p>Here is my XAML:</p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="White"&gt;
      &lt;Grid.Resources&gt;
          &lt;Style x:Key="MenuItemStyle" TargetType="HyperlinkButton"&gt;
              &lt;Setter Property="Background" Value="Blue" /&gt;
              &lt;Setter Property="Foreground" Value="White" /&gt;
              &lt;Setter Property="HorizontalContentAlignment" Value="Center" /&gt;
          &lt;/Style&gt;
      &lt;/Grid.Resources&gt;
  
      &lt;Grid x:Name="Root" HorizontalAlignment="Right" VerticalAlignment="Top"&gt;
          &lt;HyperlinkButton 
              x:Name="hl"  
              Style="{StaticResource MenuItemStyle}"
              MouseEnter="hl_MouseEnter" MouseLeave="hl_MouseLeave"&gt;
              &lt;HyperlinkButton.Content&gt;
                  &lt;Grid&gt;
                      &lt;TextBlock Text="MenuRoot" /&gt;
                  &lt;/Grid&gt;
              &lt;/HyperlinkButton.Content&gt;
          &lt;/HyperlinkButton&gt;
  
          &lt;Popup x:Name="p"&gt;
              &lt;Popup.Child&gt;
                  &lt;HyperlinkButton 
                      Style="{StaticResource MenuItemStyle}"&gt;
                      &lt;HyperlinkButton.Content&gt;
                          &lt;StackPanel&gt;
                              &lt;TextBlock Text="Sub" /&gt;
                          &lt;/StackPanel&gt;
                      &lt;/HyperlinkButton.Content&gt;
                  &lt;/HyperlinkButton&gt;
              &lt;/Popup.Child&gt;
          &lt;/Popup&gt;
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>and my code:</p>
  
  <pre><code>    private void hl_MouseEnter(object sender, MouseEventArgs e)
      {
          p.HorizontalOffset = -p.ActualWidth;
          p.IsOpen = true;
      }
  
      private void hl_MouseLeave(object sender, MouseEventArgs e)
      {
          p.IsOpen = false;
      }
  </code></pre>
  
  <p>I have tried using the popup's child's width, but this is set to 0 during the MouseEnter event, because it is hidden.</p>
  
  <p>I'm new to Silverlight so any help would be appreciated.</p>