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的自动录屏软件,很多细节很多功能需要处理,毕竟一个完美的录屏软件不是你随随便便就可以写出来的.首先参考了大部分的录屏软件,在研发的过程中遇到了很多的问题:比如 ...
随机推荐
- @spoj - ADAMOLD@ Ada and Mold
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个长度为 N 的序列 A,将其划分成 K + 1 段,划分 ...
- Timer和DispatcherTimer简单使用
1. 设定计时器相关属性,使用委托方法处理事件触发 DispatcherTimer dispatcherTimer= new DispatcherTimer(); dispatcherTimer.Ti ...
- DFS-生日蛋糕
生日蛋糕 一道深搜题,看了这两个博客才懂的. http://blog.csdn.net/blesslzh0108/article/details/53486168 http://blog.csdn.n ...
- android 重写系统进度条
转载自http://blog.csdn.net/codingandroid/article/details/8495074 自定义progressbar现在要自定义一个等待的时候转动的小圈,相信大家也 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十章:混合
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十章:混合 代码工程地址: https://github.com/j ...
- navicat for mysql 在Mac上安装后没有连接列表,就是左边的那一列连接项目怎么办?
在连接数处打对勾就可以了
- 2019-3-27-win10-uwp-动画移动滑动条的滑块
title author date CreateTime categories win10 uwp 动画移动滑动条的滑块 lindexi 2019-03-27 10:51:32 +0800 2019- ...
- VSCode 设置 CPP 代码风格
VSCode 设置 CPP 代码风格 按 Ctrl+, 打开设置,输入 format 找到. { BasedOnStyle: Google, IndentWidth: 4 }
- Java练习 SDUT-2504_多项式求和
多项式求和 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 多项式描述如下: 1 - 1/2 + 1/3 - 1/4 + ...
- 学习layui框架
Layui是一款功能齐全的前端框架,需要引入对应的CSS文件和JS文件,附属官网链接:Layui官网