M
M
Michael2015-06-20 16:42:18
WPF
Michael, 2015-06-20 16:42:18

How to implement binding?

I am using NotifyIcon from Windows Forms in my WPF application. I need to bind the value of one NotifyIcon context menu to a value in settings. But I can't figure out how to do it.
The code:

// Create NotifyIcon
var notifyIcon = new System.Windows.Forms.NotifyIcon();
notifyIcon.Icon = new System.Drawing.Icon(Properties.Resources.IconLogo, new System.Drawing.Size(16, 16));

// Add context menu
notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu();
var menuItem = new System.Windows.Forms.MenuItem(Properties.Resources.MenuItem, NotifyIconContextMenu_Click);
menuItem.Checked = Properties.Settings.Default.MenuItemChecked;// TODO Need to add binding here
notifyIcon.ContextMenu.MenuItems.Add(menuItem);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-06-21
@gmikhail94

No way, there are no bindings in WinForm as such. Rewrite using NotifyIcon for WPF.
www.codeproject.com/Articles/36468/WPF-NotifyIcon#...
https://www.nuget.org/packages/Hardcodet.NotifyIco... link to nuget package.
www.hardcodet.net/projects/wpf-notifyicon main project page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question