日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

WPF 实现任务栏角徽

發布時間:2023/12/4 asp.net 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WPF 实现任务栏角徽 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?WPF開發者QQ群:?340500857? | 微信群 -> 進入公眾號主頁?加入組織

歡迎轉發、分享、點贊、在看,謝謝~。??

01

效果預覽

效果預覽(更多效果請下載源碼體驗):

一、TaskbarItemInfoExample.xaml代碼如下?

<Window x:Class="WPFDevelopers.Samples.ExampleViews.TaskbarItemInfoExample"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:WPFDevelopers.Samples"Owner="{x:Static local:App.CurrentMainWindow}"WindowStartupLocation="CenterOwner" Title="TaskbarItemInfoExample"mc:Ignorable="d" Height="211" Width="363"d:DesignHeight="450" d:DesignWidth="800"><Window.TaskbarItemInfo><TaskbarItemInfo /></Window.TaskbarItemInfo><Window.Resources><DataTemplate x:Key="TaskbarIcon"><Border Width="20" Height="20"Background="{StaticResource PrimaryPressedSolidColorBrush}"BorderBrush="{StaticResource WhiteSolidColorBrush}" BorderThickness="2"><TextBlock Text="{Binding}" TextAlignment="Center" Foreground="White" VerticalAlignment="Center"/></Border></DataTemplate></Window.Resources><WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center"><Button Content="增加" Style="{StaticResource PrimaryButton}" Height="30" Width="120" Click="Button_Click" Tag="add"/><Button Content="移除" Style="{StaticResource PrimaryButton}" Height="30" Width="120" Click="Button_Click" Tag="remove"/></WrapPanel> </Window>

二、TaskbarItemInfoExample.xaml.cs 代碼如下

using System; using System.Collections.Generic; using System.Linq; using System.Text; 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.Navigation; using System.Windows.Shapes;namespace WPFDevelopers.Samples.ExampleViews {/// <summary>/// TaskbarItemInfoExample.xaml 的交互邏輯/// </summary>public partial class TaskbarItemInfoExample : Window{int iconWidth = 20;int iconHeight = 20;RenderTargetBitmap renderTargetBitmap;ContentControl contentControl;public TaskbarItemInfoExample(){InitializeComponent();this.Loaded += (s, e) =>{renderTargetBitmap = new RenderTargetBitmap(iconWidth, iconHeight, 96, 96, PixelFormats.Default);contentControl = new ContentControl();contentControl.ContentTemplate = ((DataTemplate)Resources["TaskbarIcon"]);};}private void Button_Click(object sender, RoutedEventArgs e){var btn = sender as Button;switch (btn.Tag.ToString()){case "add":CurrentTaskbarItemInfo("99");break;case "remove":TaskbarItemInfo.Overlay = null;break;default:break;}}void CurrentTaskbarItemInfo(string value){contentControl.Content = value;contentControl.Arrange(new Rect(0, 0, iconWidth, iconHeight));renderTargetBitmap.Render(contentControl);TaskbarItemInfo.Overlay = (ImageSource)renderTargetBitmap;}} }

源碼地址

github:https://github.com/yanjinhuagood/WPFDevelopers.git

gitee:https://gitee.com/yanjinhua/WPFDevelopers.git

WPF開發者QQ群:?340500857?

blogs:?https://www.cnblogs.com/yanjinhua

Github:https://github.com/yanjinhuagood

出處:https://www.cnblogs.com/yanjinhua

版權:本作品采用「署名-非商業性使用-相同方式共享 4.0 國際」許可協議進行許可。

轉載請著名作者 出處 https://github.com/yanjinhuagood

總結

以上是生活随笔為你收集整理的WPF 实现任务栏角徽的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。