• 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">
  • 相关阅读:
    iOS 数据存储
    iOS 中@property() 括号中,可以填写的属性?
    iOS 中关闭键盘方法
    iBeacons 资源汇总
    iOS7 下去掉状态栏(全屏)
    监听器HttpSessionListener
    监听器 HttpSessionBindingListener
    servlet 3.0 的使用
    工厂模式小例子 getDaoImp
    servlet和filter初始化
  • 原文地址:https://www.cnblogs.com/SeNaiTes/p/9435372.html
Copyright © 2020-2023  润新知