views:

35

answers:

0

I have a list box item that I wish to dynamically resize. However I don't want it to resize to the width of the largest element, but to the width of a specific element.

This comes from the datatemplate:

<StackPanel>
  <!-- this first item wants to have a width forced to that of the next item -->
  <TextBlock TextWrapping="WrapWithOverflow" HorizontalAlignment="Left">

  </TextBlock>

  <Border>
      <!-- this content dynamically resizes -->
  </Border>
</StackPanel>

I've tried binding the Width of the TextBlock to the ActualWidth of the border but this doesn't update correctly - the widths start off incorrect and only change after using an expander inside the border to force the widths to recalculate.

How do I make this happen correctly?