Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XAML WPF User-controls , +
Hello there,
 
I have a little problem with using a non-standard user control in my existing WPF project, not critical, but very annoying. I'm trying to use the WPF NotifyIcon[^] by Philipp Sumi in my WPF project. I added a reference, added the namespace in XAML and C#, but the designer doesn't recognize the type. If I compile or debug, however, everything seems to work fine and I can use the control just as it was intended.
 
This leaves me with a working control that's just hard to use, since I can't take advantage of IntelliSense in the XAML code. Oddly enough, it doesn't even recognize my local type and gives me the same error message about a not found type and a missing assembly as the one I get with the TaskbarIcon.
 
I tried taking the same steps in a new project, without doing anything else before, and it worked, so I'm baffled why it behaves differently in two different projects (both target .NET 3.5, if that's important). Maybe someone can give me a hint on how to make this work? I have using Hardcodet.Wpf.TaskbarNotification; in my C#, and here is what my XAML looks like. If you need anything else to see what's going on, please ask.
 
<<Window x:Class="ASM_Informer.MainWindow"
        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"
        xmlns:local="clr-namespace:ASM_Informer.UI"
        Title="MainWindow" Height="Auto" Width="Auto">
    <Grid>
        <tb:TaskbarIcon x:Name="tb" ToolTipText="hello world">
            <tb:TaskbarIcon.TrayPopup>
                <local:DispoRMUC/>
            </tb:TaskbarIcon.TrayPopup>
        </tb:TaskbarIcon>
    </Grid>
</Window>
 

TaskbarIcon and DispoRMUC (my own user control that is found in the UI namespace) are the types that the designer apparently can't find and that show the error message.
I'm using the German version of Visual Studio 2010 (Professional), so I only have the German error message ("Fehler - Der tb:TaskbarIcon-Typ wurde nicht gefunden. Alle Assemblyverweise müssen vorhanden sein, und alle Assemblys, auf die verwiesen wird, müssen erstellt worden sein."), so I'll roughly translate: "Error - the tb:TaskbarIcon-type was not found. All assembly references must exist and all referenced assemblies must have been built.".
 
Many thanks in advance for anyone who takes the time to look into this. I hope someone can help me with this.
Posted 14-Mar-11 22:56pm
Comments
SAKryukov at 15-Mar-11 11:48am
   
Are you saying all compiles and runs correctly but designer is not showing now? It happens.
Did you try to clean up and rebuild all from scratch?
--SA
Belua85 at 16-Mar-11 3:07am
   
Yes, exactly. As I said before, it's rather an annoyance than a critical error, but still it's.. well, annoying :)
 
I cleaned up and rebuilt, unfortunately it didn't make a difference. But thanks for the advise anyway!
 
Edit: Just to clarify, not only does the designer not show it, the XAML editor also marks the "TaskbarIcon" type with an error, saying that it could not be found.
SAKryukov at 16-Mar-11 3:33am
   
Hm... hard to say without the full project showing the condition... Frankly, I learned to minimize XAML (only dictionary, layout and binding, never events -- auto-generate event handlers is evil), so I don't create blockers of this sort. Also, do you use revision control? A must have, even for smallest projects, you always can trace back your steps...
--SA
Belua85 at 16-Mar-11 4:08am
   
Yes, the whole thing sits in a Team Foundation Server. But even with this, I haven't yet been able to find out exactly what's causing the problem, especially since even the local namespace is making the same problems. Is there anything specific you'd need to see? I don't want to spam the place by posting my whole project.
Anyways, I'll keep eye out and post back here if I find out what's causing this, but for now I guess I'll just move this stuff out of the XAML like you suggested so I don't get spammed by false errors all the time. I have a deadline and have probably already spent too much time tracing this problem than I should have. Thanks for your help!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The WPF Designer in Visual Studio is a basic designer. But the Visual Studio 2010 has better WPF Designer. The rendering of Design Time depends on the Controls and Complex design used in that particular Window or UserControl.
 
For example:
If you have a control which load records from DB on when initialized that the Designer will fail to show the Design, because if would not connect to DB unless you run the application.
 
But in your case, the problem is with the TaskbarIcon control. If you have the source code, try adding the project as reference and see.
  Permalink  
Comments
Belua85 at 16-Mar-11 3:54am
   
Thanks very much for the advice. I tried adding the project, but the result was exactly the same. Any other hints?
Venkatesh Mookkan at 17-Mar-11 2:51am
   
Then you need to use a better Designer. Expression Blend 2.0 or greater is better than Visual Studio.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This has not been solved! I get problems like this all the time, even references and namespaces that do work suddenly stop working. Sometimes the intellisense sees my class in the namespace but the namespace is not recognized!
 
This really needs to be fixed.
I'd be happy to take a breaking change in the formatting if that's needed.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 405
1 Sergey Alexandrovich Kryukov 272
2 OriginalGriff 165
3 George Jonsson 159
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,890
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100