Search code examples
wpflistviewitemtemplatecornerradius

WPF ItemList ItemTemplate Border issue


I have an ItemList with an implemented ItemTemplate that looks like this:

<DataTemplate>
   <Grid Width="90" Height="100"/>
</DataTemplate>

Now this works perfectly fine as expected. The problem occurs when i try to add a Border with a curved corner.

    <DataTemplate>
       <Border BorderBrush="red" BorderThickness="1" CornerRadius="15">
          <Grid Width="90" Height="100"/>
       </Border>
    </DataTemplate>

This results in a Grid with a sharp/default corners. And BEHIND the Grid i can see the red border with curved corners.

Question: How a Grid within an ItemTemplate have a proper corner radius?


Solution

  • Try adding a Margin to the Grid so that it fits within the curved corners. My test shows that Margin="5" is a good fit for CornerRadius="15".

    Of course, if there's something inside the Grid that has a solid background, the background will still take the shape of that child element. In which case you'll need to include more of your XAML so we can see what you're doing.