You could set AllowsTransparency="True"
Background="Transparent"
WindowStyle="None"
and customize events such as maximize, minimize, and close for Window. You can also try to use the WindowChrome class.
MainWindow.xaml.cs:
<Window x:Class="RoundCornerWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RoundCornerWindow" x:Name="window"
mc:Ignorable="d" AllowsTransparency="True" Background="Transparent" WindowStyle="None"
Title="MainWindow" Height="450" Width="800">
<Border CornerRadius="25" BorderBrush="Black" BorderThickness="2" Padding="6" Background="GhostWhite">
<Grid>
<Grid VerticalAlignment="Top" Height="30" HorizontalAlignment="Right" Width="230" Margin="0,5,5,0" >
<Button Content="*" Width="25" Margin="200,0,6,0" Click="Close_Click"/>
<Button Content="[]" Width="25" Margin="170,0,32,0" Click="Maximize_Click"/>
<Button Content="-" Width="25" Margin="125,0,44,0" Click="Minimize_Click"/>
</Grid>
</Grid>
</Border>
</Window>
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Close_Click(object sender, RoutedEventArgs e)
{
window.Close();
}
private void Maximize_Click(object sender, RoutedEventArgs e)
{
if (window.WindowState == WindowState.Normal)
{
window.WindowState = WindowState.Maximized;
}
else
{
window.WindowState = WindowState.Normal;
}
}
private void Minimize_Click(object sender, RoutedEventArgs e)
{
window.WindowState = WindowState.Minimized;
}
}
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.