当WindowStyle=“None”时,设置AllowsTransparency="True",则不会出现黑色Border,然后可以另外设置外边的Border和BorderThickness;

当WindowStyle=“None”时,生成的窗体无法移动,此时需要定义MouseMove="Window_MouseMove"事件,实现鼠标左键按下可拖动窗口;

xaml代码如下:

<Window x:Class="CustomWindowDemo.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:CustomWindowDemo"
mc:Ignorable="d" MouseMove="Window_MouseMove"
WindowStyle="None" AllowsTransparency="True" BorderBrush="Orange" BorderThickness="3,0,3,3"
Title="MainWindow" Height="" Width="">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height=""></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height=""></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="" Background="Orange">
<TextBlock Margin="20,5,5,5" Foreground="Red" Text="TestWindow" FontSize="" VerticalAlignment="Center"/>
</StackPanel>
<TextBlock Margin="20,30" FontSize="" Text="This is a Test Window of customized." Grid.Row="" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
<StackPanel Grid.Row="" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Name="Cancel" Click="Cancel_Click" Margin="0,5,20,5" Height="" Width="">Cancel</Button>
<Button Name="Confirm" Click="Confirm_Click" Margin="20,5,0,5" Height="" Width="">Confirm</Button>
</StackPanel>
</Grid>
</Window>

后台代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes; namespace CustomWindowDemo
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
} private void Confirm_Click(object sender, RoutedEventArgs e)
{
this.Close();
} private void Cancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
} private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
//Window.DragMove();
}
}
}
}

WPF设置窗口模式(Windowstyle=“None”)的更多相关文章

  1. c# WPF 设置窗口一直在其中窗口后面/底层窗口

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  2. 工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox

    原文:工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox 1. 背景 因为最近在使用wpf开发桌面端应用,在查看页面需要把TextBox和Combox等控件设置为只读的.原本是个很简 ...

  3. WPF 自定义窗口

    在WPF中,经常需要对窗口进行设置,下面讲讲常用的几个设置. 1.无边框窗口 WindowStyle="None" 窗口样式无 AllowsTransparency="T ...

  4. WPF 关于窗口的一些显示效果

    0. 一些常用尺寸大小: 1920x1080; 1600x900; 1280x720; 1024x576; 1. 设置窗口的边框样式 使用 Window.WindowStyle 属性可以设置窗口的边框 ...

  5. WPF 同一窗口内的多线程/多进程 UI(使用 SetParent 嵌入另一个窗口)

    原文 WPF 同一窗口内的多线程/多进程 UI(使用 SetParent 嵌入另一个窗口) WPF 的 UI 逻辑只在同一个线程中,这是学习 WPF 开发中大家几乎都会学习到的经验.如果希望做不同线程 ...

  6. wpf 自定义窗口,最大化时覆盖任务栏解决方案

    原文:wpf 自定义窗口,最大化时覆盖任务栏解决方案 相信很多人使用wpf时会选择自定义美观的窗口,因此会设置WindowStyle="None" 取消自带的标题栏.但这样使用 W ...

  7. WPF自定义窗口最大化显示任务栏

    原文:WPF自定义窗口最大化显示任务栏 当我们要自定义WPF窗口样式时,通常是采用设计窗口的属性 WindowStyle="None" ,然后为窗口自定义放大,缩小,关闭按钮的样式 ...

  8. WPF将窗口置于桌面下方(可用于动态桌面)

    WPF将窗口置于桌面下方(可用于动态桌面) 先来看一下效果: 界面元素很简单,就一个Button按钮,然后写个定时器,定时更新Button按钮中的内容为当前时间,下面来介绍下原理,和界面组成. 窗口介 ...

  9. 2000条你应知的WPF小姿势 基础篇<74-77 WPF 多窗口Tips>

    在正文开始之前需要介绍一个人:Sean Sexton. 来自明尼苏达双城的软件工程师.最为出色的是他维护了两个博客:2,000ThingsYou Should Know About C# 和 2,00 ...

随机推荐

  1. 【C++深入浅出】设计模式学习之单例模式

    但凡成为大家公认的模式,都是有一些不可小觑的威力,今天分享一个简单的设计模式:单例模式. 单例模式用于一些只希望有一个实例的类或者只希望执行一次的操作:校长只能有一个.老板只能有一个.用户点击弹窗只希 ...

  2. [转] C++ Redistributable Package版本详解

    我们使用的程序常常都需要C++ Redistributable Package的支持.C++ Redistributable Package有众多版本,给安装带了不便. 目前(2013-12-04) ...

  3. sqlite3使用教程1 SQLite 命令

    http://www.runoob.com/sqlite/sqlite-commands.html 本章将向您讲解 SQLite 编程人员所使用的简单却有用的命令.这些命令被称为 SQLite 的点命 ...

  4. 中国大概能用的NTPserver地址

    133.100.11.8 prefer210.72.145.44203.117.180.36131.107.1.10time.asia.apple.com64.236.96.53130.149.17. ...

  5. file_put_contents() failed to open stream: Permission denied 问题解决

    很长时间没有写PHP了,今天突然有个需求要写一个保存文件的功能. function downloadFile( $url , $savePath = '' ) {     $fileName = ge ...

  6. Android 文件读写的例子

    import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStrea ...

  7. [Bootstrap] 4. Typogrphy

    What is Typography When we talk about typography, it's a big subject! Which of the following fall un ...

  8. android126 zhihuibeijing 极光推送

    https://www.jpush.cn/ 张三把消息发送给自己的服务器,自己的服务器将消息发送给极光推送,然后极光推送将消息发送给妹子. 清单文件: <?xml version="1 ...

  9. 删除vector中的偶数元素,删除list中的奇数元素

    #include<vector> #include<list> #include<iostream> using namespace std; int main() ...

  10. CSS——选择器

    css选择器 css选择器可分为:标签(元素)选择器,ID选择器,类选择器,属性选择器,后代选择器,子代选择器,相邻兄弟选择器和兄弟选择器.... 标签选择器: //E{attr:value;attr ...