I have XAML that looks like this:
In this case/dilemma, you can leverage Xamarin's ContentView class.
You can think of ContentView as a sub-class or child of a ContentPage. So, basically, if you have a Xamarin page that is a ContentPage. And a ContentView can be a view or sub-element within a ContentPage. Both of them can have their own structure:
A ContentPage XAML (ex. MainContentPage.xaml)
...
A ContentView XAML (ex. ChildContentView.xaml)
...
And the ContentPage class (ex. MainContentPage.cs) would look possibly like this:
namespace Your.Package
{
public class MainContentPage : ContentPage
{
public MainContentPage()
{
//Some code here, binding, initialization etc.
//Create an object of the ChildContentView code behind/class
ChildContentView childView = new ChildContentView();
//Add the childView to the MainLayout of the ContentPage
this.MainLayout.Children.Add(childView);
InitializeComponent();
}
}
}
And in your ChildContentView.cs (code behind) you can basically do the same coding as what you can do in the code behind of any ContentPage class. You can add StackLayout, you can do binding, and you can use other inherited methods from the TemplatedView parent class. See this link for more information.