Reputation: 545
I am trying to apply rounded corners to a Stackpanel that is located inside a grid cell. I'm using a tag with CornerRadius. Instead of having the border surround the stackpanel, it instead stretches to surround the parent grid cell. Like this:
I use the following XAML:
<Border Grid.Row="0" Grid.Column="1" BorderBrush="#FF252A30" CornerRadius="5,5,5,5" BorderThickness="2,2,2,2">
<StackPanel Grid.Row="0" Grid.Column="1" x:Name="stackpanelContactlist" Height="336" Margin="0,113,43,113" Background="#FF252A30" d:LayoutOverrides="Width">
Content of Stackpanel
</StackPanel></Border></Grid>
I'm quite new to WPF, so I'm betting it's something simple - Anyone have any suggestions on how to fix this, so the rounded borded gets applied to the child stackpanel instead of the parent grid cell?
Thanks on advance.
Upvotes: 2
Views: 8967
Reputation: 20746
Just move the margin attribute (Margin="0,113,43,113"
) from StackPanel to the border.
Also you can remove Grid.Row="0" Grid.Column="1"
from the stack panel as these are not needed there.
Upvotes: 3