使用MvvmCross的Xamarin表单5.7第一个视图未加载

时间:2018-04-15 19:26:12

标签: xamarin.forms mvvmcross

我有一个Xamarin应用程序和MvvmCross 5.7,并希望将它完整地移动到Xamarin Forms。它按预期构建和启动,但第一页未加载。

enter image description here

我根据此模板创建了项目:https://github.com/martijn00/MvxForms

我还创建了一个测试项目,以查看我现有项目是否有问题:https://github.com/NPadrutt/XFTestProject

有人能说出我错过的东西吗?

2 个答案:

答案 0 :(得分:0)

添加从MvxSplashScreenActivity继承并使用方法覆盖的SplashScreen活动:

    protected override void TriggerFirstNavigate()
    {
        StartActivity(typeof(MainActivity));
        base.TriggerFirstNavigate();
    }

或者将这些行添加到MainActivity中的OnCreate方法:

        var startup = Mvx.Resolve<IMvxAppStart>();
        startup.Start();
        InitializeForms(bundle);

答案 1 :(得分:0)

您不必在MainActivity中呼叫startup.Start(),也不需要初始化xamarin表单。现在已经为您完成了(在mvvmcross sources中查看RunAppStart MvxFormsAppCompatActivity类的WelcomView方法。

通过GitHub回购快速浏览,看起来您并未使用[MvxContentPagePresentation()]属性(例如example from MvvmCross Playground)来装饰您的观点(即WelcomeView.xaml.cs)。将其添加到Private Sub C1Chart2_MouseClick(sender As Object, e As MouseEventArgs) Handles C1Chart2.MouseClick Dim SeriesOutput As Integer Dim PointOutput As Integer Dim DistanceOutput As Integer Dim items As String() = New String() {InputLabel10.Text, InputLabel9.Text, InputLabel8.Text, InputLabel7.Text} Dim unitHData As String() = New String() {FormatPercent((CDbl(lblPersen00.Text) / 100)), FormatPercent((CDbl(lblPersen05.Text) / 100)), FormatPercent((CDbl(lblPersen10.Text) / 100)), FormatPercent((CDbl(lblPersen20.Text) / 100))} C1Chart2.ChartGroups.Group0.CoordToDataIndex(e.X, e.Y, CoordinateFocusEnum.XandYCoord, SeriesOutput, PointOutput, DistanceOutput) Debug.WriteLine("Series Index : " & SeriesOutput.ToString()) Debug.WriteLine("Point Index : " & PointOutput.ToString()) Debug.WriteLine("Distance from Point: " & DistanceOutput.ToString()) 'MessageBox.Show(PointOutput) If PointOutput.ToString <> "" Then MessageBox.Show("X : " & items(PointOutput) & ControlChars.Cr & ControlChars.Lf & "Y : " & unitHData(PointOutput)) End If End Sub 文件中,然后检查是否有帮助

如果它是一个新项目,您可能需要考虑使用最新版本的MvvmCross(v6)。有一个很棒的step by step guide to setup Xamarin.Forms with it by Nick Randolph