简体   繁体   中英

WPF Creating an instance of a class in xaml

I have a problem with creating the instance of a class in xaml file. I thought you can do it like this:

<src:MyDataClass x:Key="data"/>

in the resource part of the user control and then use it in the xaml file (for example bind to it).

But even tough the class I created is located in the same namespace it says that:

"The type was not found. Verfiy that all assemblies were built, etc".

How to get it right? is there another method?

Thanks for suggestions.

Well obviously you have to add the right namespace to your xaml. The namespace which contains the class you want instantiate. After reading this , you should be able to solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM