Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Studio creates files with wrong namespace

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

like image 868
Alexandre D. Avatar asked Dec 03 '25 01:12

Alexandre D.


1 Answers

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.

like image 162
Jason Avatar answered Dec 05 '25 15:12

Jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!