zoukankan      html  css  js  c++  java
  • WPF 去除系统窗体边框,自定义移动窗体

     方法一:

    去除系统窗体边框:

    <Window x:Class="PracticeProject.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:PracticeProject"
            mc:Ignorable="d"
            Title="MainWindow" Height="642" Width="1280" 
         WindowChrome.WindowChrome
    ="{DynamicResource WindowChromeKey}"> <Window.Resources> <WindowChrome x:Key="WindowChromeKey"> <WindowChrome.ResizeBorderThickness> <Thickness>0</Thickness> </WindowChrome.ResizeBorderThickness> </WindowChrome> </Window.Resources>

    移动窗体事件:

            <Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Background="#336699" MouseDown="Border_MouseDown"></Border>

    移动窗体后台隐藏代码:

            /// <summary>
            /// 移动窗体
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Border_MouseDown(object sender, MouseButtonEventArgs e)
            {
                this.DragMove();
            }

    别忘记,移动窗体的那个Border被元素遮挡的部分是移动不了的。

    方法二:

    <Window x:Class="PracticeProject.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:PracticeProject"
            mc:Ignorable="d"
            Title="MainWindow" Height="642" Width="1280" WindowStyle="None">
  • 相关阅读:
    Spring AOP 随记
    Java设计模式系列 — 构造器模式
    【Java线程安全】 — 常用数据结构及原理(未完结)
    【最佳实践】好用的Quartz管理器类
    Timer和时间调度
    Java9之HashMap与ConcurrentHashMap
    记一次maven的包冲突经历
    hbase高可用集群部署(cdh)
    HBase 1.2.6 完全分布式集群安装部署详细过程
    hadoop-2.7.3完全分布式部署
  • 原文地址:https://www.cnblogs.com/SeNaiTes/p/9435372.html
Copyright © 2011-2022 走看看