Non-Rectangular window : Window « Windows Presentation Foundation « VB.Net






Non-Rectangular window

Non-Rectangular window
    

<Window x:Class="Windows.TransparentWithShapes"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="NonRectangularWindowSample" Width="210" Height="170"
  WindowStyle="None" AllowsTransparency="True" Background="Transparent">
  <Grid>
    <Path Stroke="DarkGray" StrokeThickness="1" SnapsToDevicePixels="True">

      <Path.Fill>
        <LinearGradientBrush StartPoint="0.2,0" EndPoint="0.8,1" >
          <LinearGradientBrush.GradientStops>
            <GradientStop Color="White"  Offset="0"></GradientStop>
            <GradientStop Color="White"  Offset="0.45"></GradientStop>
            <GradientStop Color="LightBlue" Offset="0.9"></GradientStop>
            <GradientStop Color="Gray" Offset="1"></GradientStop>
          </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
      </Path.Fill>

      <Path.Data>
        <PathGeometry>
          <PathGeometry.Figures>
            <PathFigure StartPoint="20,0" IsClosed="True">
              <LineSegment Point="140,0"></LineSegment>
              <ArcSegment Point="160,20" Size="20,20" SweepDirection="Clockwise"></ArcSegment>
              <LineSegment Point="160,60"></LineSegment>
              <ArcSegment Point="140,80" Size="20,20" SweepDirection="Clockwise"></ArcSegment>
              <LineSegment Point="70,80"></LineSegment>
              <LineSegment Point="20,80"></LineSegment>
              <ArcSegment Point="20,0" Size="20,20" SweepDirection="Clockwise"></ArcSegment>
            </PathFigure>
          </PathGeometry.Figures>
        </PathGeometry>
      </Path.Data>
      <Path.RenderTransform>
        <ScaleTransform ScaleX="1.3" ScaleY="1.3"></ScaleTransform>
      </Path.RenderTransform>

    </Path>

    <StackPanel Margin="5">
      <Button HorizontalAlignment="Right" Click="cmdClose_Click" Margin="0,5,10,0">x</Button>
    </StackPanel>
  </Grid>
</Window>
//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Input

Namespace Windows

  Public Partial Class TransparentWithShapes
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub

    Private Sub window_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
      Me.DragMove()
    End Sub

    Private Sub cmdClose_Click(sender As Object, e As RoutedEventArgs)
      Me.Close()
    End Sub
  End Class
End Namespace

   
    
    
    
  








Related examples in the same category

1.Custom Window
2.Set window size in XAMLSet window size in XAML
3.A simple user-login XAML pageA simple user-login XAML page
4.User login screen with no layout or formattingUser login screen with no layout or formatting
5.Automatically Size the Main Application Window to Accommodate Its ContentAutomatically Size the Main Application Window to Accommodate Its Content
6.Window.CommandBindingsWindow.CommandBindings
7.Window OwnershipWindow Ownership
8.Window.DragMoveWindow.DragMove
9.Window Closing and Closed eventWindow Closing and Closed event
10.Creating the main panel and add to Window in CodeCreating the main panel and add to Window in Code
11.Change window cursorChange window cursor
12.Show window based on button nameShow window based on button name
13.Listen to Window loaded eventListen to Window loaded event
14.Create Window and add window closing event handlerCreate Window and add window closing event handler
15.Activate window, close window, bring window to frontActivate window, close window, bring window to front
16.Set a Default ButtonSet a Default Button
17.Window Preview Key EventsWindow Preview Key Events
18.Window with Menu, ToolBar, StatusBarWindow with Menu, ToolBar, StatusBar
19.Order of precedence for sizing-related properties that are implemented by Window.Order of precedence for sizing-related properties that are implemented by Window.
20.Use Window Activated and Deactivated event to control a media fileUse Window Activated and Deactivated event to control a media file
21.Transparent WindowTransparent Window
22.Animated Video WindowAnimated Video Window
23.Use WindowState to make full screen window, change resize mode to NoReSize
24.Do not handle events until Window is fully initialized.Do not handle events until Window is fully initialized.
25.Window On Mouse move eventWindow On Mouse move event
26.Window On Mouse up eventWindow On Mouse up event
27.Window mouse down eventWindow mouse down event
28.Window Preview mouse down eventWindow Preview mouse down event
29.Window mouse up eventWindow mouse up event
30.Load resource from Window ResourcesLoad resource from Window Resources
31.Launch a window with defined XAMLLaunch a window with defined XAML
32.Create a non-rectangular windowCreate a non-rectangular window
33.Close a window with Escape key pressedClose a window with Escape key pressed
34.Display window as dialogDisplay window as dialog
35.Windows Transparent BackgroundWindows Transparent Background
36.Save Window Position to RegistrySave Window Position to Registry
37.Center a Window to ScreenCenter a Window to Screen