Pregunta

I tried to use this link: http://msdn.microsoft.com/en-us/library/ff407130.aspx . But whenever I debug it for some reason it throws an error :

The type 'src:MyVirtualizingStackPanel' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

And another error:

'src' is an undeclared prefix. Line 13, position 22.' XML is not valid

I copied the class and methods into the MainWindow class and the XAML. Am I missing anything here?

¿Fue útil?

Solución

At the end of the day, you are mistaken about your XML Namespace. If you type your error minus the name into a search engine, you will see something:

The type was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built

All of the results will point to the fact that you have not provided the correct XML Namespace for your project. Now we don't have your project in front of us... only you do, so only you can work out what your Namespace problem is. You mentioned something in a comment that made me suspicious.

You said The name-space is set automatically, but when I asked you to tell me exactly what that meant, you didn't, so I still don't know what you meant. Either way, it doesn't matter, but that could be a cause of your problem. Here are some other possible causes:

Maybe your MyVirtualizingStackPanel class is defined in a different class/project to where you specified.

Maybe you need to include the assembly=XXX part of the XML Namespace.

Maybe you have not included the CLR Namespace in your MyVirtualizingStackPanel class.

Either way, this is definitely an XML Namespace problem, so just keep looking/experimenting and you'll find the problem eventually. You can find out exactly how to add an XML Namespace from the XAML Namespaces and Namespace Mapping for WPF XAML page on MSDN.

Otros consejos

Yes, you need to specify the namespace where the MyVirtualizingStackPanel class comes from.

In the beginning of your XAML, add:

xmlns:src="clr-namespace:XXX"

where XXX is the namespace.

See MSDN.

You have to import in the xaml the namespace srcto use this On the top of the page you do:

xmlns:src="yourProjectPath"

than you can use the MyVirtualizingStackPane class.

add the XMLNS in the top,

Here look at the example

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

Add a reference to 'PresentationFramework' - you will find it in: Add reference... -> Assemblies -> Framework

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top