How to constrain the width and height of <Border> element to be equal to its inner contents?

silverlight-4.0, wpf, xaml

Solution

Set the border and the inner grid `HorizontalAlignment` and `VerticalAlignment` to `Center`. (or just the border should do it)

Problem

``` <Grid x:Name="mainGrid"> <Border BorderBrush="Black"> <Grid Name="detailGrid"> ``` Here, the `detailGrid` and its `border` takes complete Width and Height, as available from the outer `mainGrid`, where as the contents inside the `detailGrid` are having Width and Height that is much much lesser. How can I constrain the Width and Height of `Border` or/and `detailGrid` to fit to its contents, so the the Outer Grid's background is visible ?

Original source