0
我嘗試使用WPF Notify圖標http://www.codeproject.com/Articles/36468/WPF-NotifyIcon。 我創建了一個新的wpf項目,我從示例項目中導入了dll,然後複製了xaml部件和代碼。 XAML:如何使用WPF NotifyIcon
<Window x:Class="trayicon.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Title="MainWindow" Height="350" Width="525">
<Grid>
<!--
in order to create a NotifyIcon, all you need is the
namespace declaration (see above on line 4) and a simple
declaration
-->
<tb:TaskbarIcon
IconSource="Error.ico"
ToolTipText="hello world"
/>
</Grid>
</Window>
C#代碼:
using Hardcodet.Wpf.TaskbarNotification;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Navigation;
using System.Windows.Shapes;
namespace trayicon
{
/// <summary>
/// Logica di interazione per MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//Note: XAML is suggested for all but the simplest scenarios
TaskbarIcon tbi = new TaskbarIcon();
tbi.Icon = Resources.Error;
tbi.ToolTipText = "hello world";
}
}
}
有一個在線路的錯誤tbi.Icon = Resources.Error; 如果我評論該行,我在行中獲得了XamlParseException ToolTipText =「hello world」
你能幫忙嗎?謝謝