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">
  • 相关阅读:
    apply 无循环拼接数组
    匿名函数自调的三种方法
    移动元素时,translate要比margin好
    Tesseract库原理分析
    [转]基于OCR的图片字符识别可行性研究
    [转]C&C++图形图像处理开源库
    [转]OCR识别的开源分析
    [转]众多OCR软件
    [转]常用OCR软件介绍
    [转]浅谈OCR之Tesseract
  • 原文地址:https://www.cnblogs.com/SeNaiTes/p/9435372.html
Copyright © 2011-2022 走看看