vb.net - 安装安装程序 vb.net 后系统托盘图标不显示
问题描述
我创建了一个带有通知图标的 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
解决方案
推荐阅读
- r - 使用 Igraph 在 R 中的单词图
- c# - 如何将旋转转换为 0 - 1 浮点数
- c++ - 避免信号处理程序线程中繁忙处理的选项?
- javascript - Nodejs 和 SQLite 如何创建多个表?
- flutter - 如何查看使用的是什么设备?
- laravel - 无法在公用文件夹 laravel 上存储图像上传
- javascript - javascript中文件的最后修改日期
- latex - PGFP 坐标轴刻度
- reactjs - .create() on mongoose 模式错误,“此表达式不可调用”-TypeScript
- javascript - 如何解决我的不和谐机器人遇到的这个错误