Reputation: 121
I am working on Xamarin.Forms and I have a situation where have to render 4 different (ContentPage) pages on Tabs.So I'm using TabbedPage and adding different paged to parent page. Now the issue is when I come to tabbedpage all 4 pages are getting renderd on different tabs. Is there any way so that I can see 4 tabs but when a particular tab is clicked at the time of click event it should load page dynamically.
Page_1 = new Page_1() { Title = "Page_1" , Icon="icon_1.png"};
Page_2 = new Page_2() { Title = "Page_2", Icon="icon_2png"};
Page_3 = new Page_3() { Title = "Page_3", Icon="icon_3.png"};
Page_4 = new Page_4() { Title = "page_4, Icon="icon_4.png"};
Children.Add(Page_1);
Children.Add(Page_2);
Children.Add(Page_3);
Children.Add(Page_4);
I want to load all pages dynamically.Any help ?
Upvotes: 0
Views: 1121
Reputation: 16199
In your content page do
private bool _appeared = false;
public override void OnAppearing()
{
base.OnAppearing();
// To avoid repeating loading it. Remove if you want to refresh every time.
if (!_appeared)
{
// Load from here
_appeared = true;
}
}
This way they only load when the page is viewed
Upvotes: 1