【问题标题】:Changing MainPage between AppShell and NagivationPage breaks app screen在 App Shell 和 Navigation Page 之间更改 MainPage 会破坏应用程序屏幕
【发布时间】:2019-06-28 00:43:24
【问题描述】:

我发现了有关在 AppShell 和 NagivationPage 之间更改 MainPage 的 Xamarin.Forms 4.0 问题。

很容易重现问题。

1) 在 Visual Studio 2019 中使用 AppShell 模板创建新的 Xamarin.Forms 4.0 解决方案。

2) 将内容页面添加到 Views 文件夹 (LoginPage.xaml)

3) 像这样在 App.xaml.cs 中更改 MainPage;

    public App()
    {
        InitializeComponent();

        DependencyService.Register<MockDataStore>();
        //MainPage = new AppShell();
        MainPage = new NavigationPage(new Views.LoginPage());
    }

4) 像这样更改 LoginPage 中的 MainPage(我在 LoginPage.xaml 中添加了一个 Button);

    private void LoginButton_Clicked(object sender, EventArgs e)
    {
        Application.Current.MainPage = new AppShell();
    }

5) 在 AppShell 添加一个 MenuItem 并像这样添加 MenuItem Click 事件处理程序;

private void LogoutMenuItem_Clicked(object sender, EventArgs e) 
{
   Application.Current.MainPage = new NavigationPage(new Views.LoginPage());
}

6) 构建并运行应用程序

7) “登录和注销”操作会使应用程序屏幕像附加的屏幕截图一样损坏。

https://www.dropbox.com/s/skbgti26v6m2x3u/Screenshot_20190627-181115.png?dl=0



App MainPage 改成这样;

NavigationPage(new Views.LoginPage()) => new AppShell() => NavigationPage(new Views.LoginPage()).

这是实现登录功能的常见模式,我认为这可能是一个 XF 错误。

我的测试环境是 Windows 10 Pro 上的 Visual Studio 2019,我更新了 XF 4.0。

是否有任何解决方案或解决方法可以解决此问题?

最好的问候。

【问题讨论】:

标签: xamarin xamarin.forms


【解决方案1】:

干得好!在Xamarin Forms Github 中填写问题,以便他们修复

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-08
    • 2021-03-15
    相关资源
    最近更新 更多