映射XAML命名空间未检测到 [英] mapping XAML Namespace not detecting

查看:113
本文介绍了映射XAML命名空间未检测到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have created a datagrid which displays a Table of records populating from a Database
& would like to animate the cells of the datagrid when certain condition is met.
For this I created a converter class named **BlinkConverter** that inherits IValueConverter.

to put this converter into action, I have mapped the project namespace onto the xaml editor as

           xmlns:local="clr-namespace:BlinkApplication"

Note: BlinkApplication is the name of my Project

After adding this, I am trying to create an instance of my BlinkConvertor class for Binding with Windows.Resources collection as

            <Window.Resources>
            <local:BlinkConverter x:key="Blink"></local:BlinkConverter>
            </Window.Resources>

here my Intellisense is not detecting the class BlinkCoverter after I type *"local: "* , even if I try to type, I have an error stating "The type local:BlinkConverter was not found. Verify that you are missing an assembly reference and that all referenced assemblies have been built."

Even though I have added the entire project under the xmlns in my xaml editor .
What is wrong here ? have I missed any reference ?

推荐答案

如果您添加了转换器但尚未构建项目,则会出现该错误。您添加到项目中的任何新类必须在xaml解释器拾取之前构建。



其次,请确保您没有名称空间例如,如果您创建了一个behavior文件夹,并且您拥有该文件夹中行为的cs文件,则Visual Studio可能会将该类放在BlinkApplication.Behaviors。您的:本地引用必须与此匹配。查看包含转换器类的文件的顶部,看看是否有命名空间声明。



我找到的最好的事情是添加代码转换器,构建项目,然后进入xaml并添加命名空间。 Intellisense会弹出可用的,你可以在那里找到它。这可以确保你已经正确宣布它。



最后,确保你公开你的转换器。可能看起来很傻但是如果你不能在xaml中使用它。
If you have added the converter and have not built the project, you will get that error. Any new classes you add to the project must be built before they will be picked up by the xaml interpreter.

Secondly, make sure you don''t have a namespace problem. For example, if you created a behaviors folder and you have the cs file for the behavior in that folder, Visual Studio would have likely put that class at BlinkApplication.Behaviors. Your :local reference will have to match that. Look at the top of the file containing the converter class and see if there is a namespace declaration.

The best thing I''ve found is to add the code for the converter, build the project, then go into the xaml and add the namespace. Intellisense will pop-up the available ones and you can find it in there. That ensures you''ve got it declared properly.

Finally, make sure you declared your converter Public. May seem silly but it won''t be available in xaml if you don''t.


你在使用VS2010吗?我有时也会遇到这种情况,并检查我实际上缺少的是什么,但我猜VS正在遇到错误。尝试重建并忽略稍后将识别的智能感知。
Are you using VS2010? I also experience that sometimes, and check what I am actually missing, but I guess VS is experiencing bug. Try to rebuild and ignore the intellisense it will be recognize later on.


这篇关于映射XAML命名空间未检测到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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