title: Attach property is not returning the value
body: <p>I have an attached property declared for my custom panel as:</p>
  
  <pre><code>public static readonly DependencyProperty WeightProperty = DependencyProperty.RegisterAttached(
          "Weight", typeof(double), typeof(WeightedPanel),
                  new FrameworkPropertyMetadata(1.0, 
                      FrameworkPropertyMetadataOptions.AffectsParentMeasure |
                      FrameworkPropertyMetadataOptions.AffectsParentArrange ));
  
  public static void SetWeight(DependencyObject obj, double weight)
  {
      obj.SetValue(WeightProperty, weight);
  }
  
  public static double GetWeight(DependencyObject obj)
  {
      return (double) obj.GetValue(WeightProperty);
  }
  </code></pre>
  
  <p>It works fine if I define the panel as:</p>
  
  <pre><code>&lt;local:WeightedPanel Grid.Row="0" Height="200"&gt;
      &lt;Button local:WeightedPanel.Weight="8" /&gt;
      &lt;Button local:WeightedPanel.Weight="2"/&gt;
  &lt;/local:WeightedPanel&gt;
  </code></pre>
  
  <p>But if I use this panel as <code>ItemsPanelTemplate</code> for a <code>ListBox</code>, it always returns the default value in <code>ArrangeOverride</code>.</p>
  
  <pre><code>&lt;ListBox Grid.Row="2" Height="100"&gt;
      &lt;ListBox.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;local:WeightedPanel /&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ListBox.ItemsPanel&gt;
      &lt;Button local:WeightedPanel.Weight ="6" /&gt;
      &lt;Button local:WeightedPanel.Weight ="4"/&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>I also noticed that when the custom wrap panel is used in a <code>ListBox</code>, it sends <code>double.PositiveInfinite</code> in Arrange method and therefore Arrange is never able to set the values. The same works fine when used all by itself</p>
  
  <p>Thanks</p>