Skip to content

Instantly share code, notes, and snippets.

@JoshClose
Created November 15, 2011 16:39
Show Gist options
  • Save JoshClose/1367541 to your computer and use it in GitHub Desktop.
Save JoshClose/1367541 to your computer and use it in GitHub Desktop.
Creating a Custom Window in WPF
<Window x:Class="CustomWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Title="Window1" Height="300" Width="300">
<Grid>
</Grid>
</Window>
<Window x:Class="CustomWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Title="Window1" Height="300" Width="300"
AllowsTransparency="True" WindowStyle="None" Background="Transparent">
<Grid>
</Grid>
</Window>
<Window x:Class="CustomWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Title="Window1" Height="300" Width="300"
AllowsTransparency="True" WindowStyle="None" Background="Transparent">
<Border BorderThickness="1" BorderBrush="Black" Background="White"
Margin="0" CornerRadius="10">
</Border>
</Window>
<Window x:Class="CustomWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Title="Window1" Height="300" Width="300"
AllowsTransparency="True" WindowStyle="None" Background="Transparent">
<Border BorderThickness="1" BorderBrush="Black" Background="White"
Margin="0" CornerRadius="10">
<Border Height="40" Background="#01000000" VerticalAlignment="Top"
CornerRadius="10,10,0,0" MouseLeftButtonDown="DragWindow"/>
</Border>
</Window>
using System.Windows;
using System.Windows.Input;
namespace CustomWindow
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
protected void DragWindow( object sender, MouseButtonEventArgs e )
{
DragMove();
}
}
}
<Window x:Class="CustomWindow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Title="Window1" Height="300" Width="300"
AllowsTransparency="True" WindowStyle="None" Background="Transparent">
<aero:SystemDropShadowChrome CornerRadius="10" Margin="10">
<Border BorderThickness="1" BorderBrush="Black" Background="White"
Margin="0" CornerRadius="10">
<Border Height="40" Background="#01000000" VerticalAlignment="Top"
CornerRadius="10,10,0,0" MouseLeftButtonDown="DragWindow"/>
</Border>
</aero:SystemDropShadowChrome>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment