Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF-NotifyIcon not working when moved into an XAML dictionary
    text
    copied!<p>I'm using <a href="http://www.hardcodet.net/projects/wpf-notifyicon" rel="nofollow">WPF-NotifyIcon</a>, and am following <a href="http://www.codeproject.com/Articles/36468/WPF-NotifyIcon" rel="nofollow">this tutorial</a>, and it works when I put the XAML code in my MainWindow.xaml, however once I move onto the "Creating the NotifyIcon from a Resource Dictionary" part it stops showing up in the tray.</p> <p>I have a Dictionary1.xaml with the following code in it:</p> <pre><code>&lt;ResourceDictionary 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"&gt; &lt;!-- Globally declared notify icon --&gt; &lt;tb:TaskbarIcon x:Key="MyNotifyIcon" IconSource="/Notifier;component/assets/icon_16x.ico" ToolTipText="Notifier" MenuActivation="RightClick" Visibility="Visible" /&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>An App.xaml with the following code:</p> <pre><code>&lt;Application x:Class="Notifier.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"&gt; &lt;Application.Resources&gt; &lt;ResourceDictionary Source="Dictionary1.xaml" /&gt; &lt;/Application.Resources&gt; &lt;/Application&gt; </code></pre> <p>and I just copied over the App class code from that section of the tutorial.</p> <p>What am I doing wrong? Why isn't the icon showing up? And on a related note, how can I have a program that doesn't have a MainWindow, but instead just runs from the taskbar (Which would be ideal with this control).</p> <p><strong>Edit:</strong></p> <p>I took out the StartupUri from App.xaml and put the following code in my App.xaml.cs:</p> <pre><code> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); tb = (TaskbarIcon)FindResource("MyNotifyIcon"); tb.Visibility = Visibility.Visible; //new MyClassIWantToInstantiate(); } </code></pre> <p>It works perfectly, but is there anything wrong with doing this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload