Xamarin Studio creates files with wrong namespace

679 Views Asked by At

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...

1

There are 1 best solutions below

1
On BEST ANSWER

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.