How do I put a border on my grid in C#/WPF?
This is what I would like it to be, but puts a border around the whole thing instead of the grid control I put in my application.
<Grid>
<Border BorderBrush="Black" BorderThickness="2">
<Grid Height="166" HorizontalAlignment="Left" Margin="12,12,0,0" Name="grid1" VerticalAlignment="Top" Width="479" Background="#FFF2F2F2" />
</Border>
... and so on ...
If you just want an outer border, the easiest way is to put it in a Border control:
The reason you’re seeing the border completely fill your control is that, by default, it’s HorizontalAlignment and VerticalAlignment are set to Stretch. Try the following:
This should get you what you’re after (though you may want to put a margin on all 4 sides, not just 2…)