WPF实现透明无边框悬浮球
想在工作中实现一个透明无边框并且具有动画功能的悬浮球,如图片所示,但在网上搜了之后发现发现使用wpf实现的基本没有,所以将自己实现的过程放在这里,希望给需要的一个方便,过程是这样的:
<Windowx:Class="WPFFloatBall.View.FloatAlarmWIndow"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"Title="FloatAlarmWIndow"Width="100"Height="100"AllowsTransparency="True"Background="Transparent"ResizeMode="NoResize"ShowInTaskbar="False"Topmost="True"WindowStartupLocation="CenterScreen"WindowStyle="None"mc:Ignorable="d"><Window.Resources><FontFamily x:Key="DigitalFontFamily">pack://application:,,,/Resource/Font/#Digital</FontFamily></Window.Resources><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="8*" /><ColumnDefinition Width="8*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="8*" /><RowDefinition Height="8*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /></Grid.RowDefinitions><!--这里是外圈圆型转动的权,在style实现了动画效果,其实就是一个在图片加载之后调用一个storyboard实现DoubleAnimation--><GridGrid.Row="0"Grid.RowSpan="10"Grid.Column="0"Grid.ColumnSpan="10"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Image Source="pack://application:,,,/Resource/Image/Out4.png" Style="{StaticResource Clockwise}" /></Grid><GridGrid.Row="2"Grid.RowSpan="6"Grid.Column="2"Grid.ColumnSpan="6"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Image Source="pack://application:,,,/Resource/Image/Out3.png" Style="{StaticResource AntiClockwise}" /></Grid><GridName="out2"Grid.Row="3"Grid.RowSpan="4"Grid.Column="3"Grid.ColumnSpan="4"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Image Source="pack://application:,,,/Resource/Image/Out2.png" Style="{StaticResource AntiClockwise}" /></Grid><GridGrid.Row="4"Grid.RowSpan="2"Grid.Column="4"Grid.ColumnSpan="2"><Grid.ColumnDefinitions><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /><ColumnDefinition Width="1*" /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /><RowDefinition Height="1*" /></Grid.RowDefinitions><GridGrid.Row="1"Grid.RowSpan="6"Grid.Column="1"Grid.ColumnSpan="6"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Image Source="pack://application:,,,/Resource/Image/Out1.png" /></Grid><GridGrid.Row="0"Grid.RowSpan="8"Grid.Column="0"Grid.ColumnSpan="8"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"><Grid.Background><ImageBrush ImageSource="pack://application:,,,/Resource/Image/Center0.png" Stretch="UniformToFill" /></Grid.Background></Grid><TextBlockName="tbAlarmNumber"Grid.Row="2"Grid.RowSpan="4"Grid.Column="2"Grid.ColumnSpan="4"HorizontalAlignment="Center"VerticalAlignment="Center"FontFamily="{StaticResource DigitalFontFamily}"FontSize="20"Foreground="White"Text="111" /><TextBlockGrid.Row="5"Grid.RowSpan="2"Grid.Column="1"Grid.ColumnSpan="6"HorizontalAlignment="Center"VerticalAlignment="Bottom"FontSize="10"Foreground="White"Text="有病毒" /></Grid></Grid>
</Window>
首先,在window里给了,固定宽度高度,透明这样只会显示前端区域
Width="100"Height="100"AllowsTransparency="True"Background="Transparent"
在下面用grid加载了多个图片,外层动画圆环在style实现了动画效果,其实就是一个在图片加载之后调用一个storyboard实现DoubleAnimation转动,最终的效果是想最上面的动态图所示。
如果想看源代码可以看这里iamgongjun/WPFFloatBall: 一个由WPF创建的透明无边框悬浮球(Transparent borderless floating ball created by WPF) (github.com)https://github.com/iamgongjun/WPFFloatBall
WPF实现透明无边框悬浮球相关推荐
- 01.WPF中制作无边框窗体
[引用:]http://blog.csdn.net/johnsuna/article/details/1893319 众所周知,在WinForm中,如果要制作一个无边框窗体,可以将窗体的FormBor ...
- 【C++·Qt】Qt透明无边框窗口以及拖动
窗口透明 1.窗口整体透明(包含其子空控件) //窗口以及子控件都透明 //setAttribute(Qt::WA_WState_WindowOpacitySet); //网上说直接设置不起作用,需 ...
- WPF 调用API修改窗体风格实现真正的无边框窗体
原文:WPF 调用API修改窗体风格实现真正的无边框窗体 WPF中设置无边框窗体似乎是要将WindowStyle设置为None,AllowTransparency=true,这样才能达到WinForm ...
- Simple WPF:实现一个透明、无边框、鼠标穿透的WPF窗体
WPF 透明窗体和鼠标事件穿透 一个自定义WPF窗体的解决方案,借鉴了吕毅老师的WPF制作高性能的透明背景的异形窗口一文,并在此基础上增加了鼠标穿透的功能.可以使得透明窗体的鼠标事件穿透到下层,在下层 ...
- C# WPF 建立无边框(标题栏)的登录窗口的示例
前言:笔者最近用c#写WPF做了一个项目,此前未曾做过完整的WPF项目,算是一边学一边用,网上搜了不少资料,效率当然是不敢恭维的,有时会在一些很简单的问题上纠结很长时间,血与泪的教训可不少. 不过,正 ...
- 无边框窗体的移动(winform/wpf)
WinForm 引入命名空间 using System.Runtime.InteropServices;无边框移动[DllImport("user32.dll")]public s ...
- WPF无边框拖动、全屏、缩放
原文:WPF无边框拖动.全屏.缩放 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/lwwl12/article/details/78059361 先看效果 ...
- electron-vue 制作悬浮球
1.background.js配置文件 'use strict' import {updateHandle} from './utils/update.js'; import ElectronStor ...
- Qt实现半透明、无边框、可自由移动、不规则的窗体
目录 预期效果 功能要点 实现步骤 进一步扩展应用 预期效果 先出示效果图一张,如果不是读者需要的,读者可以看完效果图之后就关闭本网页啦. 功能要点 窗口无边框 可自由拖动 背景透明度自定义 边框可设 ...
最新文章
- 6月技术福利限时免费领
- Power BI for Office 365(七) Power BI站点
- 查看字符集 oracle
- 用Visual Studio .Net 2003开发PHP程序
- springmvc代码详细(五种映射,绑定参数,处理json数据,文件上传,转发,拦截器的实现)
- 求任意10个数中的正数之和及个数,函数实现体会地址传递
- [react] React中getInitialState方法的作用是什么
- c语言用栈实现计算器加法运算,请问,用c语言做一个计算器 包括+-*/()的运算 用栈 该怎么做...
- 苹果手机连接电脑一直噔噔蹬的响,而且没有反应
- iview select 内存泄漏_Vue遇到的内存泄漏排查处理
- idc机房建设费用_机房建设方案及报价清单.doc
- viper12a电源电路图_VIPer12A功率开关电源IC.pdf
- 从全面了解高级计量经济学体系+stata实操+实证研究前沿+论文+大数据机器学习+空间计量......._Stata高级计量经济学 陈强
- Qos介绍及功能->分类标记->流量管理(令牌桶)->拥塞管理与拥塞避免
- Qt:使用元对象编辑器Moc
- 今天是星期五,上班已经三个礼拜了
- 亚商投资顾问 早餐FM/0411中证金融下调证券公司保证金比例
- 赴美工作常识(Part 6 - 绿卡排队)
- RabbitMQ简介以及AMQP协议
- KL散度和交叉熵的对比介绍