根页错误xamarin形式

时间:2017-09-01 15:40:24

标签: xamarin

我的根页面通过单击后面给出错误,而不是在后台,发生未处理的错误"发生了未处理的异常。我的命令有问题吗? enter image description here

我做了以下尝试,当我调用除Rootpage之外的其他页面时,错误不会发生

public class RootPage : MasterDetailPage
{
    Dictionary<MenuIndex, NavigationPage> Views { get; set; }

    public RootPage()
    {
        Title = "teste";

        Views = new Dictionary<MenuIndex, NavigationPage>();

        Master = new MenuPage(this)
        {
            Icon = "ic_menu_white.png"
        };

        NavigateAsync(MenuIndex.Page1);
    }

    public void NavigateAsync(MenuIndex id)
    {
        Page newPage;

        if (!Views.ContainsKey(id))
        {
            switch (id)
            {
                case MenuIndex.Page1:
                        Views.Add(id, new ControlNavigationApp(new Page1(), "#04518c"));
                    break;
                case MenuIndex.Page2:
                    Views.Add(id, new ControlNavigationApp(new Page2(), "#04518c"));
                    break;
                case MenuIndex.Page3:
                    Views.Add(id, new ControlNavigationApp(new Page3(), "#04518c"));
                    break;
                default:
                        Views.Add(id, new ControlNavigationApp(new Page1(), "#04518c"));
                    break;
            }
        }

        newPage = Views[id];

        if (newPage == null)
            return;

        //pop to root for Windows Phone
        if (Detail != null && Device.OS == TargetPlatform.WinPhone)
        {
            //await Detail.Navigation.PopToRootAsync();
        }

        Detail = newPage;

        if (Device.Idiom != TargetIdiom.Tablet)
            IsPresented = false;
    }

    //comand example
    protected override bool OnBackButtonPressed()
    {
        return base.OnBackButtonPressed();
    }
}

0 个答案:

没有答案