方便自己以后用,原文: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遮罩~~~(搬运过来的)的更多相关文章

  1. C# WPF遮罩对话框(Popup Message Overlay/ Dialog Host)

    时间如流水,只能流去不流回! 点赞再看,养成习惯,这是您给我创作的动力! 本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform.W ...

  2. WPF loading遮罩层 LoadingMask

    原文:WPF loading遮罩层 LoadingMask 大家可能很纠结在异步query数据的时候想在wpf程序中显示一个loading的遮罩吧 今天就为大家介绍下遮罩的制作 源码下载 点击此处 先 ...

  3. 【WPF】BusyIndicator做Loading遮罩层

    百度了一下,粗略看了几个国内野人的做法,花了时间看下去感觉不太好用(比如有Loading居然只是作为窗体的一个局部控件的,没法全屏遮罩,那要你有何用?),于是谷歌找轮子去. 好用的轮子:http:// ...

  4. WPF 通过透明度遮罩和变换制作倒影效果

      倒影效果 代码 <Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http:/ ...

  5. “WPF老矣,尚能饭否”—且说说WPF今生未来(上):担心

    近日微软公布了最新的WPF路线图,一片热议:对于老牌控件提供商葡萄城来说,这是WPF系列控件一个重要的机遇,因此,Spread Studio for WPF产品做了一次重要更新,并随着Spread S ...

  6. [WPF系列]Adorner应用-自定义控件ImageHotSpot

    引言 项目中有时需要在图片上标注热区,在HTML中有<area>标签,但在WPF中目前还没现成的控件来实现这这一功能.至于图片热区功能有道词典的[图解词典]是个不错的例子,如图1: 图 1 ...

  7. WPF的二维绘图(一)——DrawingContext

    DrawingContext比较类似WinForm中的Graphics 类,是基础的绘图对象,用于绘制各种图形,它主要API有如下几种: 绘图API 绘图API一般形为DrawingXXX系列,常用的 ...

  8. 一个简单WPF登陆界面,包含记住密码,自动登录等功能,简洁美观

    简介:这是一个自己以前用WPF设计的登陆界面,属于一个实验性的界面窗体,如果用于产品还很有不足.但也是有一点学习价值.后台代码略有复杂,但基本上都有注释 分类,略有代码经验的一般都能看懂. 登陆界面外 ...

  9. WPF 截屏软件开发

    最近由于工程需要开始研发基于Windows的自动录屏软件,很多细节很多功能需要处理,毕竟一个完美的录屏软件不是你随随便便就可以写出来的.首先参考了大部分的录屏软件,在研发的过程中遇到了很多的问题:比如 ...

随机推荐

  1. MVC设计之MVC设计模式(介绍)

    mvc介绍; 首先先引用一个百度百科的介绍: MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用 ...

  2. SPSS函数之期和时间函数

    SPSS函数之期和时间函数 CTIME.DAYS(timevalue)数值.返回 timevalue 中的天数(包括有小数位的天数),timevalue 必须为时间格式的数值或表达式,如 TIME.x ...

  3. Android开发-API指南-<activity-alias>[原创译文]

    http://blog.sina.com.cn/s/blog_48d491300100zmg5.html

  4. MyBatis动态SQL(二)

    1.foreach foreach语句用来遍历数组和集合对象.标签中的属性: collection属性:值有三种list.array.map open属性:表示调用的sql语句前缀添加的内容 clos ...

  5. 大侦探福老师——幽灵Crash谜踪案

    闲鱼Flutter技术的基础设施已基本趋于稳定,就在我们准备松口气的时候,一个Crash却异军突起冲击着我们的稳定性防线!闲鱼技术火速成立侦探小组执行嫌犯侦查行动,经理重重磨难终于在一个隐蔽的角落将其 ...

  6. tp3 key json 分页

    //json 强制转换为array $arr[$key]['checkpro'] = json_decode($val['checkpro'],JSON_FORCE_ARRAY);    $arr[$ ...

  7. matplotlib绘制热力图

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/jin_tmac/article/deta ...

  8. 洛谷P1910 L国的战斗之间谍

    //二维费用01背包 #include<bits/stdc++.h> using namespace std; ; ; ; int v1[maxn],v2[maxn],w[maxn],n, ...

  9. H3C 数据链路层

  10. laravel asset()函数

    asset() 使用当前请求的scheme(HTTP或HTTPS)为前端资源生成一个URL: $url = asset('img/photo.jpg'); laravel自带了laravel-mix, ...