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 ...
随机推荐
- 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
本文转载:http://blog.csdn.net/playing9c/article/details/7471918 http://blog.csdn.net/beelinkerlidejun/ar ...
- TFS上使用Beyond Compare来比较源码
In Visual Studio, go to the Tools menu, select Options, expand Source Control, (In a TFS environment ...
- SliderSkin
<?xml version="1.0" encoding="utf-8"?> <s:Skin xmlns:fx="http://ns ...
- Samba Linux和Windows互访
之前一直用的sshfs manager,但是会出现造成电脑黑屏的情况.网上也没找到其它类似的软件. 后面打算用Samba 直接搜到一篇很强大的文章. 1. 下载及安装Samba 推荐用yum来安装, ...
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 水题
A. Olesya and Rodion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/p ...
- Nginx详细配置
#运行用户#user nobody; #启动进程,通常设置成和cpu的数量相等或者2倍于cpu的个数(具体结合cpu和内存).默认为1worker_processes 1; #全局的错误日志和日志 ...
- Nginx + Tomcat + Session
分别下载 tomcat http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.22/bin/apache-tomcat-7.0.22.tar.gz n ...
- Eclipse安装ADT失败解决办法
Eclipse的版本是3.5.2,配置Android的开发环境时遇到问题…… 按照Android官方文档一步步安装,到了安装Eclipse的ADT插件时,提示“requires 'org.eclips ...
- Linux 服务器相关的一下链接
Apache 虚拟主机 VirtualHost 配置 以下是各操作系统的配置方法. Redhat Enterprise Linux Ubuntu Linux Windows Mac OS http:/ ...
- Android View的绘制机制流程深入详解(三)
本系列文章主要着重深入介绍Android View的绘制机制及流程,第三篇主要介绍并分析视图状态以及重绘流程,首先剖析了 视图的几种状态,然后在深入分析视图的重绘机制流程. 真题园网:http://w ...