我正在制作一个Xamarin Forms应用程序,该解决方案称为RESTTest
,我的共享项目称为RestApp
。
在我的共享项目中,我有一个名为ViewModels
的文件夹,其中包含一个名为MainViewModel.cs
的类。
我有一个名为MainPage.xaml
的页面,该页面后面有一个名为MainPage.xaml.cs
的代码。在我的XAML中,我试图包含这样的Viewmodels文件夹:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:RestApp"
x:Class="RestApp.MainPage"
xmlns:ViewModels="clr-namespace:RestApp.ViewModels;assembly=RestApp">
但是当我像这样向页面添加绑定(bind)时:
<ContentPage.BindingContext>
<ViewModels:MainViewModel />
</ContentPage.BindingContext>
我收到一个未处理的异常:
Type ViewModels:MainViewModel not found in xmlns clr-namespace:RestApp.ViewModels;assembly=RestApp
我想念什么?
最佳答案
删除 namespace 中的“; assembly = RestApp”,并将链接器行为设置为“仅链接SDK组合件”对我而言有效,并解决了该问题!
关于c# - Xamarin-在xmlns clr-namespace中找不到类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44665152/