问题描述
我创建了一个带有通知图标的 WPF 应用程序。通知图标出现在托盘中,通过 BIN 文件夹 exe 运行应用程序。 在为应用程序创建设置之后。安装程序安装成功。但是通知图标没有出现在任务栏托盘中。
**NotifyIconResources.xaml**
<tb:TaskbarIcon x:Key="NotifyIcon"
IconSource="/Image/icon.ico"
ToolTipText="Notification"
LeftClickCommand="{Binding ShowWindowCommand}"
>
<tb:TaskbarIcon.DataContext>
<local:NotifyIconviewmodel />
</tb:TaskbarIcon.DataContext>
**application.xaml**
StartupUri="MainWindow.xaml"
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="NotifyIconResources.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
**Application.xaml.vb**
Class Application
Dim notifyIcon As TaskbarIcon
Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs)
MyBase.OnStartup(e)
notifyIcon = CType(FindResource("NotifyIcon"),TaskbarIcon)
End Sub
Protected Overrides Sub OnExit(ByVal e As ExitEventArgs)
notifyIcon.dispose()
MyBase.OnExit(e)
End Sub
End Class
**NotifyIconviewmodel.vb**
Public ReadOnly Property ShowWindowCommand As ICommand
Get
Return New DelegateCommand With {
.CanExecuteFunc = Function() Application.Current.MainWindow Is nothing,.CommandAction = Sub()
Dim window As New MainWindow()
Application.Current.MainWindow = window
Application.Current.MainWindow.Show()
End Sub
}
End Get
End Property
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)