Click here to Skip to main content
15,896,526 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried every solution on web for this question but none of them worked.I have defined namespace as follows:
xmlns:local="clr-namespace:ScheduleView;assembly=ScheduleView"


and then in
XML
<Window.Resources>
        <local:ViewModel x:Key="ViewModel"/>
</Window.Resources>



the ViewModel.cs file is also in same namespace ScheduleView and class is public.
then whats wrong? why it VS is showing this error ?
Posted

Probably, this is because you are confusing C#/.NET namespaces with XAML namespaces. Yes, they are mapped together, but it should be specified in your XAML top element's namespace declarations. Intellisense helps you to choose the write one: when you start typing in the attribute starting with "xmlns:x " (where x is any unique namespace prefix you are planning to use, Intellisense will show you the list of choices on the right of text insertion point. Just try it to see. The attribute value mapped to correct .NET namespace will be written in correct syntax for you.

For background, please see this MSDN article: https://msdn.microsoft.com/en-us/library/ms747086%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
Did you copy the view and paste it? This gives a problem at times.
Try creating the view from scratch again.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900