wpf遮罩~~~(搬运过来的)
方便自己以后用,原文:https://blog.csdn.net/lwwl12/article/details/78472235
直接上代码
public partial class BaseWindow : Window
{
public BaseWindow() : base()
{
this.Closed += Window_Closed;
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
this.ResizeMode = ResizeMode.NoResize;
} public void SyncComplete()
{
this.Dispatcher.Invoke(() =>
{
MessageBox.Show(this, "操作完成!", "提示");
});
} private void Window_Closed(object sender, EventArgs e)
{
//容器Grid
Grid grid = this.Owner.Content as Grid;
//父级窗体原来的内容
UIElement original = VisualTreeHelper.GetChild(grid, ) as UIElement;
//将父级窗体原来的内容在容器Grid中移除
grid.Children.Remove(original);
//赋给父级窗体
this.Owner.Content = original;
} public bool? ShowDialog(Window owner)
{
//蒙板
Grid layer = new Grid() { Background = new SolidColorBrush(Color.FromArgb(, , , )) };
//父级窗体原来的内容
UIElement original = owner.Content as UIElement;
owner.Content = null;
//容器Grid
Grid container = new Grid();
container.Children.Add(original);//放入原来的内容
container.Children.Add(layer);//在上面放一层蒙板
//将装有原来内容和蒙板的容器赋给父级窗体
owner.Content = container;
this.Owner = owner;
return this.ShowDialog();
}
}
xaml
<local:BaseWindow x:Class="Modules.wnd_TimeSync"
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:Modules"
mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True" Background="Transparent"
Title="wnd_TimeSync" Height="20" Width="220" Closed="Window_Closed" >
<StackPanel>
<ProgressBar Name="pb" Height="20" Width="200" Maximum="100"></ProgressBar>
</StackPanel>
</local:BaseWindow>
使用方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
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.Shapes; namespace Modules
{
/// <summary>
/// wnd_TimeSync.xaml 的交互逻辑
/// </summary>
public partial class wnd_TimeSync : BaseWindow
{
public wnd_TimeSync()
{
InitializeComponent();
} public static void ShowDialog(Window owner)
{
//弹出消息框
wnd_TimeSync box = new wnd_TimeSync();
box.ShowDialog(owner);
}
}
}
wpf遮罩~~~(搬运过来的)的更多相关文章
- C# WPF遮罩对话框(Popup Message Overlay/ Dialog Host)
时间如流水,只能流去不流回! 点赞再看,养成习惯,这是您给我创作的动力! 本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform.W ...
- WPF loading遮罩层 LoadingMask
原文:WPF loading遮罩层 LoadingMask 大家可能很纠结在异步query数据的时候想在wpf程序中显示一个loading的遮罩吧 今天就为大家介绍下遮罩的制作 源码下载 点击此处 先 ...
- 【WPF】BusyIndicator做Loading遮罩层
百度了一下,粗略看了几个国内野人的做法,花了时间看下去感觉不太好用(比如有Loading居然只是作为窗体的一个局部控件的,没法全屏遮罩,那要你有何用?),于是谷歌找轮子去. 好用的轮子:http:// ...
- WPF 通过透明度遮罩和变换制作倒影效果
倒影效果 代码 <Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http:/ ...
- “WPF老矣,尚能饭否”—且说说WPF今生未来(上):担心
近日微软公布了最新的WPF路线图,一片热议:对于老牌控件提供商葡萄城来说,这是WPF系列控件一个重要的机遇,因此,Spread Studio for WPF产品做了一次重要更新,并随着Spread S ...
- [WPF系列]Adorner应用-自定义控件ImageHotSpot
引言 项目中有时需要在图片上标注热区,在HTML中有<area>标签,但在WPF中目前还没现成的控件来实现这这一功能.至于图片热区功能有道词典的[图解词典]是个不错的例子,如图1: 图 1 ...
- WPF的二维绘图(一)——DrawingContext
DrawingContext比较类似WinForm中的Graphics 类,是基础的绘图对象,用于绘制各种图形,它主要API有如下几种: 绘图API 绘图API一般形为DrawingXXX系列,常用的 ...
- 一个简单WPF登陆界面,包含记住密码,自动登录等功能,简洁美观
简介:这是一个自己以前用WPF设计的登陆界面,属于一个实验性的界面窗体,如果用于产品还很有不足.但也是有一点学习价值.后台代码略有复杂,但基本上都有注释 分类,略有代码经验的一般都能看懂. 登陆界面外 ...
- WPF 截屏软件开发
最近由于工程需要开始研发基于Windows的自动录屏软件,很多细节很多功能需要处理,毕竟一个完美的录屏软件不是你随随便便就可以写出来的.首先参考了大部分的录屏软件,在研发的过程中遇到了很多的问题:比如 ...
随机推荐
- PHP如何输出合并单元格的表
https://mp.weixin.qq.com/s/ChPIKIv9tqmuqGyfc9Zi7Q 合并单元格的表,很多地方可以见到,比如购物车,订单合并等,今天给大家讲解一下,如何操作,虽然我用的l ...
- mysql中bigint、int、mediumint、smallint与tinyint的取值范围
https://blog.csdn.net/github_39110707/article/details/74277381 mysql数据库设计,其中对性能优化,字段类型很重要,下面对bigint. ...
- python系列之(5)PyMySQL的使用
简介 PyMySQL是在 Python3.x 版本中用于连接 MySQL 服务器的一个库,Python2中是使用mysqldb. 安装 pip3 install pymysql 创建连接 #!/usr ...
- C++运行时类型识别
通过运行时类型识别(RTTI),程序能够使用基类的指针或引用来检索这些指针或引用所指对象的实际派生类型. 通过下面两个操作符提供 RTTI: 1. typeid 操作符,返回指针或引用所指对象的实际类 ...
- AtCoder Beginner Contest 075 C bridge【图论求桥】
AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...
- mybatis分页插件pageHelper简单实用
工作的框架spring springmvc mybatis3 首先使用分页插件必须先引入maven依赖,在pom.xml中添加如下 <!-- 分页助手 --> <dependency ...
- AspNetPager 样式
使用方法: 1.引入样式表. 将 想要使用的样式表加入到本页面<style type="text/css"></style>标记中,或者新建一个css文件如 ...
- selenium 自动化点击页面
#!/usr/bin/env python# -*- coding:utf-8 -*-from selenium import webdriverfrom selenium.webdriver.com ...
- @bzoj - 4378@ [POI2015] Logistyka
目录 @description@ @solution@ @accepted code@ @details@ @description@ 维护一个长度为 n 的序列,一开始都是 0,支持以下两种操作: ...
- vue element 中自定义传值
一直以来都不知道如何传自定义的值,一直只会默认的,今天终于找到方法了. 比如这个上传图片的控件,想带当前的index过去,就这样写.其它的类似 :http-request="(file,fi ...