D23_03_非矩形窗口 (自定义窗体)

2020-12-13 15:01

阅读:292

标签:style   blog   http   io   color   ar   os   sp   strong   

soscw.com,搜素材

 

Window x:Class="demo.TransparentBackground"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="TransparentBackground" Height="300" Width="300"
        AllowsTransparency="True" WindowStyle="None"
        MouseLeftButtonDown="window_MouseLeftButtonDown"
        >
    
    Window.Background>
        ImageBrush ImageSource="shapes.png">ImageBrush>
    Window.Background>
    Grid>
        Grid.RowDefinitions>
            RowDefinition>RowDefinition>
            RowDefinition>RowDefinition>
            RowDefinition>RowDefinition>
            RowDefinition>RowDefinition>
        Grid.RowDefinitions>
        Button Margin="20">A Sample ButtonButton>
        Button Margin="20" Grid.Row="2" Click="cmdClose_Click" >CloseButton>
    Grid>
Window>

 

TransparentBackground (窗体类)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace demo
{
    /// 
    /// TransparentBackground.xaml 的交互逻辑
    /// 
    public partial class TransparentBackground : Window
    {
        public TransparentBackground()
        {
            InitializeComponent();
        }

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

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

D23_03_非矩形窗口 (自定义窗体)

标签:style   blog   http   io   color   ar   os   sp   strong   

原文地址:http://www.cnblogs.com/xiepengtest/p/4069097.html


评论


亲,登录后才可以留言!