Is it possible to include a block of XAML in another block of XAML?

后端 未结 3 1353
遇见更好的自我
遇见更好的自我 2021-02-07 03:13

I have XAML that looks like this:


   
      

        
3条回答
  •  盖世英雄少女心
    2021-02-07 03:47

    Create a directory called Templates, and then create a new View class, MyCustomGrid like so:

    Templates/MyCustomGrid.xaml:

    
    
        
            
            
        
        
    

    Templates/MyCustomGrid.xaml.cs

    using Xamarin.Forms;
    
    namespace MyProject.Templates
    {
        public partial class MyCustomGrid : Grid
        {
            public MyCustomGrid()
            {
                InitializeComponent();
            }
        }
    }
    

    To use it in another page, ie MyPage.xaml:

    
    
    
        
    
    
    

提交回复
热议问题