0
我想在我的Xamarin.Forms App.xaml的标记中定义一个viewmodel类。Xamarin.Forms ViewModel在标记没有加载dll
<xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewModels="clr-namespace:MyPCL.Client.ViewModels;assembly=MyPCL.Client"
x:Class="TestApp2.App">
<Application.Resources>
<viewModels:MainViewModel x:Key="MainViewModel"/>
</Application.Resources>
</Application>
我得到这个错误: 未处理的异常:
System.IO.FileNotFoundException:未能加载文件或程序集 'MyPCL.Client' 或它的一个依赖。
但如果我声明并初始化这个类在我的app.xaml.cs,它工作正常。为什么这会在代码后面加载,而不是在标记中加载?
这工作,但现在我得到Xamarin.Forms.Xaml.XamlParseException:位置10:6。无法分配属性“资源”:类型不匹配“MyPCL.Client.ViewModels.MainViewModel”和“Xamarin.Forms.ResourceDictionary” – shady
@shady请参阅http://stackoverflow.com/questions/40518329/uncomfort-myapp-android-has -stopped-with-contentpage-resource-in-xaml-file/40519339#40519339上述评论中描述的错误的解决方案。 – matthewrdev