Xamarin Forms: ContentPages in TabbedPage

前端 未结 3 1686
Happy的楠姐
Happy的楠姐 2021-01-05 06:40

I am trying to put some custom Content Pages into a Tabbed Page. Sadly I am not sure, how to do this with the XAML syntax. My dummy project looks like the following:

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 07:15

    You are doing it wrong. You must place the pages as the TabbedPage Children.

    Here is the solution:

    
    
      
        
        
      
    
    

    In alternative you can do it programmatically:

    public class TabsPage : TabbedPage
    {
        public TabsPage ()
        {
            this.Children.Add (new Page1 () { Title = "Home" });
            this.Children.Add (new Page2 () { Title = "Browse" });
        }
    }
    

提交回复
热议问题