我是MvvmCross 6.0和Xamarin的新手。
我正在尝试关注tutorial here that for MvvmCrosss 5.5
我按照说明,
<?xml version="1.0" encoding="utf-8" ?> <core:MvxFormsApplication xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:core="clr-namespace:MvvmCross.Forms.Core;assembly=MvvmCross.Forms" x:Class="App3.App"> </core:MvxFormsApplication>
public class CoreApp : MvxApplication { public override void Initialize() { CreatableTypes() .EndingWith("Service") .AsInterfaces() .RegisterAsLazySingleton(); CreatableTypes() .EndingWith("Client") .AsInterfaces() .RegisterAsLazySingleton(); // register the appstart object RegisterAppStart<MainPageViewModel>(); } }
public class MainPageViewModel : MvxViewModel { }
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="Center"
HorizontalOptions="Center" />
[Activity(Label = "MvvmcrossGettingStarted", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] 公共类MainActivity:MvxFormsAppCompatActivity { protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle); var startup = Mvx.Resolve<IMvxAppStart>(); startup.Start(); InitializeForms(bundle); } } public class Setup : MvxFormsAndroidSetup { public Setup():base() { } protected override IEnumerable<Assembly> AndroidViewAssemblies => new List<Assembly>(base.AndroidViewAssemblies .Union(new[] { typeof(App).GetTypeInfo().Assembly }) .Except(new[] { this.GetType().Assembly }) ); protected override Application CreateFormsApplication() { return new App(); } protected override IMvxApplication CreateApp() => new CoreApp(); }
然而,我启动了应用程序,它给了我一个空例外说&#34;捆绑&#34;在OnCreated方法中,参数为null。
P.S。本教程提到创建Setup.cs,但我不知道如何通过代码运行Setup.cs。我看不到它引用它的位置。
答案 0 :(得分:3)
在使用v 6.0时,我不确定为什么要查看5.5版本的教程。请尝试关注同一作者的step by step guide,但版本6.0
您可能还想从他的GitHub repo下载Nick的样本,以检查其运作方式。