wpf-creation of non-rectangular windows

Source: Internet
Author: User

First, the window's allowstransparency is set to True

Second, the window's background is set to Transparent

Third, the window's windowstyle is set to None

The grid in the window is set to the desired shape using clip or border

code example (using clip to implement a fillet window)

1 <Windowx:class= "Test"2 xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"3 xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"4 xmlns:d= "http://schemas.microsoft.com/expression/blend/2008"5 XMLNS:MC= "http://schemas.openxmlformats.org/markup-compatibility/2006"6 xmlns:local= "Clr-namespace:caipiaoui"7 mc:ignorable= "D"8 Title= "Test"Height= "$"Width= "$"WindowStyle= "None"allowstransparency= "True" 9 Background= "Transparent"windowstartuplocation= "Centerscreen">Ten     <GridBackground= "Blue"> One         <Grid.clip> A             <RectangleGeometryRadiusX= " the"RadiusY= " the"Rect= "0,0,500,500"></RectangleGeometry> -         </Grid.clip> -     </Grid> the </Window>

code example (using border to implement a fillet window)

1 <Windowx:class= "Test"2 xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"3 xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"4 xmlns:d= "http://schemas.microsoft.com/expression/blend/2008"5 XMLNS:MC= "http://schemas.openxmlformats.org/markup-compatibility/2006"6 xmlns:local= "Clr-namespace:caipiaoui"7 mc:ignorable= "D"8 Title= "Test"Height= "$"Width= "$"WindowStyle= "None"allowstransparency= "True" 9 Background= "Transparent"windowstartuplocation= "Centerscreen">Ten     <Grid> One         <Borderborderthickness= " the"Cornerradius= " the"Background= "Blue"></Border> A     </Grid> - </Window>

One particular note here is the location of the window background color setting:
In the clip implementation mode, the window background color is set on the grid;

In the border implementation mode, the window background color is set on the border.

wpf-creation of non-rectangular windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.