locked
wpf-notifyicon. 'MyNotifyIcon' does not exist in the current context. RRS feed

  • Question

  • I have downloaded the project from:

    http://www.hardcodet.net/wpf-notifyicon

    One of the first things I'm noticing about the project (Sample Project) is that when I view the file SimpleWindowWithNotifyIcon.xaml.cs which is located in the 01 - Declaration folder I see two errors and they are:

        The name 'MyNotifyIcon' does not exist in the current context

        The name 'InitializeComponent' does not exist in the current context

    The project builds just fine which I found to be very surprising given the red underscores under the two lines in my screenshot. I don't really understand at this point if the errors really are errors or not or what to do about them. Does anyone know more about this with wpf-notifyicon?

    What I think I understand is that MyNotifyIcon is declared in XAML not in C Sharp. As for InitializeComponent I'm still trying to determine why that would not be found in the context.

    Thank you.


    • Edited by S.e.p.y Wednesday, August 27, 2014 12:19 AM More information.
    Tuesday, August 26, 2014 9:10 PM

Answers

  • Hi Sepy,

    when you right-click on the "Sample Project" and build that one, the red underscores will disappear. (Works on my machine. :-))

    1. MyNotifyIcon: The name is specified on the TaskbarIcon-Element specified in XAML. With that name you can access that element in the codebehind-file, in this case to dispose it.

    2. The InitializeComponent-Method is defined in another file that contains a part of the partial class Samples.Tutorials.SimpleWindowWithNotifyIcon that is also in your codebehind-file. That additional file gets generated from the XAML-document. The class-name is specified with the x:Class-Attribute in XAML. When you right-click on the InitializeComponent-Method, you can select "Go to Definition" from the ContextMenu, and you'll see that generated file.

    So as long that file is not generated (for example when the XAML is invalid), the InitializeComponent-Method will be red.


    Thomas Claudius Huber

    "If you can't make your app run faster, make it at least look & feel extremly fast"

    My latest Pluralsight-course: Windows Store Apps - Data Binding in Depth

    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook


    Wednesday, August 27, 2014 7:12 AM