Xamarin Calling a TabbedPage using a Button

半城伤御伤魂 提交于 2019-12-11 17:39:35

问题


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;
}

But the result is as follows:

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

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...

Any ideas?


回答1:


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

Create two pages.

Page1.xaml:

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

Page2.xaml:

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

With the code you provided.

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

Result:




回答2:


Need more explanation about the issue,

The tabs in the Tabbedpage are dynamically created?

Suggestion: Use https://help.syncfusion.com/xamarin/tabbed-view/getting-started

it will save your time.



来源:https://stackoverflow.com/questions/58997167/xamarin-calling-a-tabbedpage-using-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!