WPF设置窗口模式(Windowstyle=“None”)
当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”)的更多相关文章
- c# WPF 设置窗口一直在其中窗口后面/底层窗口
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- 工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox
原文:工作记录--WPF自定义控件,实现一个可设置编辑模式的TextBox 1. 背景 因为最近在使用wpf开发桌面端应用,在查看页面需要把TextBox和Combox等控件设置为只读的.原本是个很简 ...
- WPF 自定义窗口
在WPF中,经常需要对窗口进行设置,下面讲讲常用的几个设置. 1.无边框窗口 WindowStyle="None" 窗口样式无 AllowsTransparency="T ...
- WPF 关于窗口的一些显示效果
0. 一些常用尺寸大小: 1920x1080; 1600x900; 1280x720; 1024x576; 1. 设置窗口的边框样式 使用 Window.WindowStyle 属性可以设置窗口的边框 ...
- WPF 同一窗口内的多线程/多进程 UI(使用 SetParent 嵌入另一个窗口)
原文 WPF 同一窗口内的多线程/多进程 UI(使用 SetParent 嵌入另一个窗口) WPF 的 UI 逻辑只在同一个线程中,这是学习 WPF 开发中大家几乎都会学习到的经验.如果希望做不同线程 ...
- wpf 自定义窗口,最大化时覆盖任务栏解决方案
原文:wpf 自定义窗口,最大化时覆盖任务栏解决方案 相信很多人使用wpf时会选择自定义美观的窗口,因此会设置WindowStyle="None" 取消自带的标题栏.但这样使用 W ...
- WPF自定义窗口最大化显示任务栏
原文:WPF自定义窗口最大化显示任务栏 当我们要自定义WPF窗口样式时,通常是采用设计窗口的属性 WindowStyle="None" ,然后为窗口自定义放大,缩小,关闭按钮的样式 ...
- WPF将窗口置于桌面下方(可用于动态桌面)
WPF将窗口置于桌面下方(可用于动态桌面) 先来看一下效果: 界面元素很简单,就一个Button按钮,然后写个定时器,定时更新Button按钮中的内容为当前时间,下面来介绍下原理,和界面组成. 窗口介 ...
- 2000条你应知的WPF小姿势 基础篇<74-77 WPF 多窗口Tips>
在正文开始之前需要介绍一个人:Sean Sexton. 来自明尼苏达双城的软件工程师.最为出色的是他维护了两个博客:2,000ThingsYou Should Know About C# 和 2,00 ...
随机推荐
- 【3D研发笔记】之【数学相关】(一):坐标系
现在开始学习3D基础相关的知识,本系列的数学相关笔记是基于阅读书籍<3D数学基础:图形与游戏开发>而来,实现代码使用AS3,项目地址是:https://github.com/hammerc ...
- MySQL内存表的特性与使用介绍
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- BZOJ 1151 傲娇的人 排序
傲娇的人 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/1151 Descrip ...
- SQL Server 2008中的hierarchyid
这也是SQL Server 2008的一个重要新增特性.主要解决的问题是拥有层次关系的表格.例如我们日常生活中用到最多的组织结构图.我们一般会用一个Region表保存区域数据,而每个区域则又可能会有相 ...
- [MODx] 4. getResources
1. Create a chunk call 'white_content' for white content: <!-- Highlights --> <div class=&q ...
- 【分享】4412开发板-嵌入式Linux开发须要掌握的基础知识和技能
本文转自迅为电子论坛:http://www.topeetboard.com 1.Linux 基础 安装Linux操作系统 Linux文件系统 Linux经常使用命令 Linux启动过程具体解释 熟悉L ...
- perl dtrace2
http://search.cpan.org/~chrisa/Devel-DTrace-Provider-1.11/lib/Devel/DTrace/Provider.pm
- C#_delegate EndInvoke
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 【转】频点CTO张成:基于Cocos2d的MMORPG开发经验
http://www.9ria.com/plus/view.php?aid=27698 作者: zhiyuanzhe3 发表时间: 2013-06-29 17:46 6月29日,由9Tech社区.51 ...
- 【转】Adobe CC 的下载地址
http://trials3.adobe.com/AdobeProducts/AEFT/12/win64/AfterEffects_12_LS20.7z http://trials3.adobe.co ...