我正在尝试使用以下代码行在 WPF 中创建系统托盘图标:
System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = new System.Drawing.Icon("main.ico");
XAML:
> <Window x:Class="WpfExample.Window1"
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> Title="Window1" Height="300" Width="300">
> <Grid>
> <Button Height="23" Margin="103,0,100,100" Name="button1"
> VerticalAlignment="Bottom">Submit</Button>
> <TextBox Height="23" Margin="77,75,81,0" Name="textBox1"
> VerticalAlignment="Top" />
> </Grid> </Window>
我已经在 Google 上搜索了解决方案,但我正在尝试学习 WPF,这是我在创建系统托盘图标时遇到的问题。我收到的消息如下所示:
无法创建在程序集“WpfExample,版本=1.0.0.0,文化=中性,PublicKeyToken=null”中定义的“Window1”的实例。调用的目标已引发异常。标记文件“Window1.xaml”第 1 行位置 9 中的错误。
谁能指出我正确的方向?