Xamarin使用按钮调用TabbedPage [英] Xamarin Calling a TabbedPage using a Button

查看:230
本文介绍了Xamarin使用按钮调用TabbedPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题.当我单击其他页面上的按钮时,我想加载TabbedPage,所以我创建了以下代码:

I have a problem. I want to load a TabbedPage when I click on a button in a different page, so I created this code:

protected void imgAdd_Clicked(object sender, EventArgs args)
{
    var tabbedPage = new TabbedPage();
    tabbedPage.Children.Add(new Page1());
    tabbedPage.Children.Add(new Page2());

    App.Current.MainPage = tabbedPage;
}

但是结果如下:

如您所见,在页面之间滑动时,图像会留下图像痕迹.

As you can see the Image leaves a trail of the image when you swipe between the pages.

但是,当我使用App.xaml.cs加载选项卡式页面时,它会正确加载而不会闪烁,因此看来只有在我从另一个页面调用选项卡式页面时才会发生...

However, when I load the Tabbed Page using the App.xaml.cs it loads correctly without the flickering, so it seems to only occur when I call the tabbed page from another page...

有什么想法吗?

推荐答案

我制作了要测试的示例.您可以在我的github上检查示例TabbedPageDemo. https://github.com/WendyZang/Test.git

I make the sample to test. You could check the sample TabbedPageDemo on my github. https://github.com/WendyZang/Test.git

创建两个页面.

Page1.xaml:

Page1.xaml:

<StackLayout >
        <Image Source="pig.jpg"></Image>
    </StackLayout>

Page2.xaml:

Page2.xaml:

<StackLayout>
        <Image Source="world.jpg"></Image>
    </StackLayout>

使用您提供的代码.

  var tabbedPage = new TabbedPage();
        tabbedPage.Children.Add(new Page1());
        tabbedPage.Children.Add(new Page2());
 App.Current.MainPage = tabbedPage;

结果:

这篇关于Xamarin使用按钮调用TabbedPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆