Question

I am trying to make the corners of a Window (WPF) rounded and it doesn't work, I tried to make the window itself transparent and add an internal border with rounded corners and it doesn't work.

Any ideas?

Was it helpful?

Solution

you need to set WindowStyle to WindowStyle.None, which will remove the chrome, then you can allow transparency which is an attribute int the Window element, and set the background color to transparent. All of this can be done as attributes to the window tag.

WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"

To make the corners rounded, use a border and set the cornerRadius property

OTHER TIPS

Don't use AllowsTransparency it's slow and buggy, take a look at this link, look for the section "Office 2007 without Aero – Or, you are responsible for everything":

https://blogs.msdn.microsoft.com/wpfsdk/2008/09/08/custom-window-chrome-in-wpf/

EDIT: some of the techniques in this post are specific to Vista, but the "Office 2007 without Aero" section works on XP (and actually describes what software that is written for Vista has to fall-back to on XP).

You also need to make a transparent border around your window that's a few pixels wide, or else the edges of your rounded corners get cut off

it may help u.

<Grid DataContext="{Binding ElementName=root}">
    <Border Background="#90000000" Visibility="{Binding Visibility}">
        <Border BorderBrush="Black" BorderThickness="1" Background="AliceBlue" 
                CornerRadius="10,0,10,0" VerticalAlignment="Center"
                HorizontalAlignment="Center">
            <Border.BitmapEffect>
                <DropShadowBitmapEffect Color="Black" 
                  Opacity="0.5" Direction="270" 
                  ShadowDepth="0.7" />
            </Border.BitmapEffect>
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock x:Name="MessageTextBlock" 
                    Text="{Binding Message}" 
                    TextWrapping="Wrap" Margin="5" />
                <UniformGrid Grid.Row="1" Margin="5" 
                          Columns="2" HorizontalAlignment="Center"
                          VerticalAlignment="Bottom">
                    <Button x:Name="OkButton"  
                          Content="Ok" Margin="2"  />
                    <Button x:Name="CancelButton" 

                          Content="Cancel" Margin="2" />
                </UniformGrid>
            </Grid>
        </Border>
    </Border>
</Grid>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top