Phone Developer
Phone Developer

Reputation: 1461

Wrap Border around content with WPF

I have a Grid defined in my WPF application. I want to wrap a Border around the Grid itself. My problem is, the Border is filling the area available to the parent area. Because this, the Border is huge, but my content is small. My XAML is defined as follows:

  <Grid>
    <Border CornerRadius="0,0,2,2" BorderBrush="Black" BorderThickness="3"  Margin="4">
      <Grid HorizontalAlignment="Center">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock Text="{Binding Path=Description}" />
        <TextBlock Text="{Binding Path=Disclaimer}" />
      </Grid>
    </Border>
  </Grid>

What am I doing wrong? How do I fix this?

Thanks!

Upvotes: 0

Views: 2413

Answers (1)

Robert Levy
Robert Levy

Reputation: 29073

you have the border inside your grid. do it like this <Border><Grid>...</Grid></Border>

Upvotes: 1

Related Questions