question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rounded border: corner radius cuts border outline off

See original GitHub issue

Hey, I’m trying to create a borderless window with custom decoration. I decided to use a rounded border for this, for example:

<Border CornerRadius="20"
        BorderBrush="Gray"
        BorderThickness="2"
        ClipToBounds="True">
	<!-- Content -->
</Border>      

Unfortunately, the corner radius cuts the gray border outline off: image

image

Is it possible to outline along the actual (rounded) boundary if a corner radius is set? Also, I noticed that the border edges look really pixelated. Is there a way to enable anti-aliasing for elements with the CornerRadius property in the rendering engine?

Some general system information:

Version 0.10.0-preview6
Host Arch Linux 5.8.12-arch1-1 (X11)
NET Core SDK 3.1.108

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
ThePBonecommented, Nov 14, 2020

Solved it by applying a small padding to the border element content to avoid overlaps with the rounded window border. Here’s my solution if anyone else runs into this issue:

<Border CornerRadius="20"
        BorderBrush="Black"
        BorderThickness="2"
        ClipToBounds="True" Padding="1"
        Background="{DynamicResource SystemControlBackgroundAltHighBrush}">
    
    <DockPanel HorizontalAlignment="Stretch"
               VerticalAlignment="Stretch"
               Name="ContentWrapper"
               Margin="2,0">
        
        <ui:CustomTitleBar Background="Transparent"></ui:CustomTitleBar>
        
        <DockPanel Background="{DynamicResource SystemControlBackgroundAltHighBrush}">
            <!-- Content -->
        </DockPanel>
        
    </DockPanel>
</Border>

image

0reactions
sabutocommented, Nov 12, 2021

See #6857 (comment)

so i read about a bit and it says to do it in the App Builder like .With(new Win32PlatformOptions { CompositionBackdropCornerRadius = 30}) if that is right it is still not working, is there anything else i need to add?

Also im not sure if it matters but i am also using Material avalonia for styling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Border is cutting off when using border-radius?
I have an image which has a 5px border around it and I wanted to round the corners of both the image and...
Read more >
border-radius - CSS: Cascading Style Sheets - MDN Web Docs
The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, ......
Read more >
Don't fail 1px outlines and rounded shapes · Issue #2222 · ...
In rounded corners using border-radius, the corner bits are no longer part of the component, by any reasonable definition of the component. And ......
Read more >
border-radius
The border-radius property takes between one and four length or percentage values, where one value sets the radius for all four corners at...
Read more >
SwiftUI Tip: How to Draw a Border with Rounded Corners
With SwiftUI, you can easily draw a border around a button or text (and it actually works for all views) using the border...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found