WPF:XAML Designer不会识别类型,但编译工作正常 [英] WPF: XAML Designer won't recognize types, but compiling works fine

查看:86
本文介绍了WPF:XAML Designer不会识别类型,但编译工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我在现有的WPF项目中使用非标准用户控件有点问题,不是很关键,但很烦人。我正在尝试使用 WPF NotifyIcon [ ^ ]。我添加了一个引用,在XAML和C#中添加了命名空间,但设计者并不认识这种类型。但是,如果我编译或调试,一切似乎工作正常,我可以像预期的那样使用控件。



这让我有一个工作控件'这很难使用,因为我无法在XAML代码中利用IntelliSense。奇怪的是,它甚至没有识别我的本地类型,并且给了我关于未找到类型和缺少程序集的相同错误消息,就像我使用TaskbarIcon一样。



我尝试在新项目中采取相同的步骤,之前没有做任何其他事情,并且它有效,所以我很困惑为什么它在两个不同的项目中表现不同(都是针对.NET 3.5,如果那样''很重要)。也许有人可以给我一些关于如何使这项工作的提示?我有在我的C#中使用Hardcodet.Wpf.TaskbarNotification; ,这就是我的XAML的样子。如果您还需要其他任何东西来查看发生了什么,请询问。



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和DispoRMUC(我自己的用户控件是在UI命名空间中找到的是设计者显然无法找到并显示错误消息的类型。

我正在使用德语版的Visual Studio 2010(专业版),所以我只有德语错误信息(Fehler - Der tb:TaskbarIcon-Typ wurde nicht gefunden.AlleAssemblyverweisemüssenvorhandensein,und alle Assemblys,auf die verwiesen wird,müssenrertelltworden sein。)所以我会粗略translate:错误 - 找不到tb:TaskbarIcon-type。所有程序集引用都必须存在,并且必须构建所有引用的程序集。。



非常感谢对于那些花时间研究这个问题的人来说。我希望有人可以帮助我。




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.

推荐答案

Visual Studio中的WPF设计器是一个基本设计器。但Visual Studio 2010具有更好的WPF设计器。设计时的渲染取决于特定窗口或UserControl中使用的控件和复杂设计。



例如:

如果你有一个控件,在初始化时加载来自DB的记录,Designer将无法显示设计,因为除非你运行应用程序否则不会连接到DB。



但是在您的情况下,问题是TaskbarIcon控件。如果你有源代码,请尝试添加项目作为参考,然后看看。
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.


这还没有解决!我总是遇到这样的问题,甚至工作的引用和命名空间也会突然停止工作。有时intellisense在命名空间中看到我的类,但命名空间无法识别!



这真的需要修复。

我''如果需要,我很乐意对格式进行重大改变。
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.


这篇关于WPF:XAML Designer不会识别类型,但编译工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆