Skip to content

Instantly share code, notes, and snippets.

@iburlakov
Created February 22, 2013 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iburlakov/5013531 to your computer and use it in GitHub Desktop.
Save iburlakov/5013531 to your computer and use it in GitHub Desktop.
WPF form of arbitrary shape
<Window x:Class="Test.ArbitraryShapeForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ArbitraryShapeForm"
AllowsTransparency="True"
Background="Transparent"
WindowStyle="None">
<Canvas Width="300" Height="300">
<Path Stroke="Gray" StrokeThickness="2">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,0">
<LineSegment Point="0,260" />
<LineSegment Point="180,260" />
<LineSegment Point="220,300" />
<LineSegment Point="260,260" />
<LineSegment Point="300,260" />
<LineSegment Point="300,0" />
<LineSegment Point="0,0" />
</PathFigure>
</PathGeometry>
</Path.Data>
<Path.Fill>
<LinearGradientBrush StartPoint="0, 0" EndPoint="0, 1">
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="Red" Offset="1.2" />
</LinearGradientBrush>
</Path.Fill>
</Path>
<Grid Canvas.Top="0" Canvas.Left="0" Height="260" Width="300">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Ololo! Where have you been?" TextAlignment="Center" Margin="0 20" />
<Button Grid.Row="1" Name="justButton" Content="Ok" Height="24" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="6" />
</Grid>
<CheckBox Canvas.Bottom="20" Canvas.Right="74" >
<CheckBox.RenderTransform>
<RotateTransform x:Name="rotate" Angle="0" CenterX="7" CenterY="7" />
</CheckBox.RenderTransform>
<CheckBox.Triggers>
<EventTrigger RoutedEvent="CheckBox.Loaded">
<BeginStoryboard>
<Storyboard Storyboard.TargetName="rotate" Storyboard.TargetProperty="Angle">
<DoubleAnimation From="0" To="360" Duration="0:0:3" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</CheckBox.Triggers>
</CheckBox>
</Canvas>
</Window>
using System;
using System.Windows;
namespace Test
{
/// <summary>
/// Interaction logic for ArbitraryShapeForm.xaml
/// </summary>
public partial class ArbitraryShapeForm : Window
{
public ArbitraryShapeForm()
{
InitializeComponent();
this.justButton.Click += (sender, e) => this.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment