码迷,mamicode.com
首页 > Windows程序 > 详细

WPF——TaskBarIconOverlay(任务栏图标叠加)

时间:2018-05-03 19:39:45      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:src   html   sources   tac   and   red   分享图片   rect   drawing   

原文:WPF——TaskBarIconOverlay(任务栏图标叠加)

技术分享图片

 

   <Window.Resources>
<DrawingImage x:Key="OverlayImageVector">
<DrawingImage.Drawing>
<GeometryDrawing Brush="Red">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0 0 16 16" RadiusX="3" RadiusY="3" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>

<DrawingImage x:Key="OverlayImage">
<DrawingImage.Drawing>
<ImageDrawing ImageSource="0726_24px_Republic_32bit_PNG.png" Rect="0 0 24 24" />
</DrawingImage.Drawing>
</DrawingImage>

</Window.Resources>


<Window.TaskbarItemInfo>
<TaskbarItemInfo />
</Window.TaskbarItemInfo>


<Grid>
<StackPanel Width="120"
HorizontalAlignment
="Center"
VerticalAlignment
="Center">
<Button x:Name="AddOverlay"
Content
="Add Overlay"
Margin
="10" />

<Button x:Name="OtherOverlay"
Content
="Other Overlay"
Margin
="10" />

</StackPanel>
</Grid>

 

 1   public partial class MainWindow : Window
2 {
3 public MainWindow()
4 {
5 InitializeComponent();
6
7 AddOverlay.Click += new RoutedEventHandler(AddOverlay_Click);
8 OtherOverlay.Click += new RoutedEventHandler(OtherOverlay_Click);
9 }
10
11 void OtherOverlay_Click(object sender, RoutedEventArgs e)
12 {
13 // TaskbarItemInfo.Overlay,获取或设置在任务栏按钮中的程序图标上方显示的图像
14 //TaskbarItemInfo.Overlay = null;
15 TaskbarItemInfo.Overlay = (ImageSource)Resources["OverlayImageVector"];
16 }
17
18 void AddOverlay_Click(object sender, RoutedEventArgs e)
19 {
20 TaskbarItemInfo.Overlay = (ImageSource)Resources["OverlayImage"];
21 }
22 }



WPF——TaskBarIconOverlay(任务栏图标叠加)

标签:src   html   sources   tac   and   red   分享图片   rect   drawing   

原文地址:https://www.cnblogs.com/lonelyxmas/p/8986712.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!