Nothing is everything.

Saturday, January 2, 2010

Nonrectangular Window, Irregular Window

<Window x:Class="MyWpfSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
AllowsTransparency="True" WindowStyle="None" Background="Transparent"
Title="Window1" Height="300" Width="300"
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>



public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}

Referenced from book WPF unleashed, page225.

No comments:

Post a Comment

Followers