1

Is there a better option to make a grid with rounded corners? Might this cause any problems?

(Example: Wanted is a corner-radius of 10 & background colour of #FF292A2E)

<Grid Height="300" Width="150" Background="Transparent"  >
                <Border x:Name="roundBorder" BorderThickness="0" CornerRadius="10" Background="#FF292A2E"/>

</Grid>
BSMP
  • 4,596
  • 8
  • 33
  • 44
GionSnow
  • 117
  • 1
  • 10
  • 1
    Define "better"? You could have `Grid` inside `Border` too. Problems? In wpf? Nah.. – Sinatr Aug 15 '19 at 13:29
  • "Might this cause any problems?" - yes. child elements positioned in corners will overlap and hide those round corners: https://i.stack.imgur.com/LQJaS.png – ASh Aug 15 '19 at 13:35
  • For clarification, do you want ALL your grids in your WPF application to always be rounded corner radius? If so, you will be better off to declare your own grid control template / style so they are assigned globally to your app. Please confirm – DRapp Aug 15 '19 at 17:15

1 Answers1

1

I imagine you more want the grid inside the border:

<Border x:Name="roundBorder" BorderThickness="0" CornerRadius="10" Background="#FF292A2E">
    <Grid Height="300" Width="150" Background="Transparent"  >


    </Grid>
</Border>

The Grid is just a means of laying out controls, so you first create Border with rounded corners and then add a Grid to this Border to which you can now add other things.

Tim Rutter
  • 4,549
  • 3
  • 23
  • 47