3

i'm currently using Xamarin Studio and i'm developing an app with the MvvmCross framework.

My issue is that, when I try to create a new file in my folder named "Views", the namespace does not contain the ".Views".

I have Xamarin.Client.iOS instead of Xamarin.Client.iOS.Views. So the MvvmCross framework doesn't find my views and return a KeyNotFoundException : could not find view for [MyViewModel]

I wonder if XCode modified my namespaces because my app worked well and now it can't find the views.

I guess it's a namespace problem but not really sure. The fact is my "View" files are not in the ".Views" namespace while they are in the "Views" folder.

How can I create my Views with the good namespace ? Because changing it in the .cs and .designer.cs file does not fix the KeyNotFoundException...

If you have any idea...

Alexandre D.
  • 711
  • 1
  • 9
  • 28
  • I would doubt that the `KeyNotFoundException` was caused by the wrong namespace - it's more likely to be caused by wrong base class, missing constructor or some other problem. If something changed, is there any way you can identify what it was - e.g. looking over a source control diff? – Stuart Jun 27 '14 at 12:27

1 Answers1

8

In Xamarin Studio, Preferences --> Source Code --> .NET Naming Policies

Check "Associate namespaces with directory names" if you want your classes to include the folder name in the namespace by default.

Jason
  • 86,222
  • 15
  • 131
  • 146