Skip to content

Instantly share code, notes, and snippets.

@dbuksbaum
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save dbuksbaum/85ad1acaa9c15aa5cecb to your computer and use it in GitHub Desktop.

Select an option

Save dbuksbaum/85ad1acaa9c15aa5cecb to your computer and use it in GitHub Desktop.
Irregular Shaped Windows in WPF
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
DragMove();
}
private void mnuExit_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void mnuMinimize_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
}
<Window x:Class="MyFunSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MyFunSample"
AllowsTransparency="True"
WindowStyle="None"
Background="Transparent"
ResizeMode="CanMinimize"
MouseDown="Window_MouseDown">
<Window.ContextMenu>
<ContextMenu>
<MenuItem Header="Minimize" Name="mnuMinimize" Click="mnuMinimize_Click"/>
<MenuItem Header="Exit" Name="mnuExit" Click="mnuExit_Click"/>
</ContextMenu>
</Window.ContextMenu>
<Border CornerRadius="20,20,20,20" Background="Cornsilk"/>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment