Window.DragMove

image_pdfimage_print


   
  


<Window x:Class="GadgetWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Height="300" Width="300"
  AllowsTransparency="True" WindowStyle="None" Background="Transparent"
  MouseLeftButtonDown="Window_MouseLeftButtonDown">
  <Grid>
    <Ellipse Fill="Red" Opacity="0.5" Margin="20">
      <Ellipse.BitmapEffect>
        <DropShadowBitmapEffect/>
      </Ellipse.BitmapEffect>
    </Ellipse>
    <Button Margin="100" Click="Button_Click">Close</Button>
  </Grid>
</Window>
//File:Window.xaml.cs

using System.Windows;
using System.Windows.Input;

public partial class GadgetWindow : Window
{
  public GadgetWindow()
  {
    InitializeComponent();
  }
  void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  {
    this.DragMove();
  }
  void Button_Click(object sender, RoutedEventArgs e)
  {
      this.Close();
  }
}