'How can I display a ContentView in a ContentPage

I created a sftabView, every SfTabItem have a ContentView so I created an other View to display it in this ContentView. so the question is how to make this happened? This is the ContentView which I wanted to display in the ContentPage

<?xml version="1.0" encoding="utf-8" ?>
<ContentView    
    xmlns="http://xamarin.com/schemas/2014/forms"
    x:Class="App5.Views.Self_Trainig"

    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  
    NavigationPage.HasNavigationBar="False">

    <ContentView.Resources>
        <ResourceDictionary>
    ............
        </ResourceDictionary>
    </ContentView.Resources>

    <ContentView.Content>
        <AbsoluteLayout>
...............
        </AbsoluteLayout>

    </ContentView.Content>
</ContentView>

and this is my ContentPage:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:tabView="clr-namespace:Syncfusion.XForms.TabView;assembly=Syncfusion.SfTabView.XForms"
             x:Class="App5.Views.Accueil">
    <ContentPage.Content>
        <tabView:SfTabView OverflowMode="DropDown" VisibleHeaderCount="3" BackgroundColor="White">
            <tabView:SfTabItem Title="Self Training">
                <tabView:SfTabItem.Content>
""the code to display it here""
                </tabView:SfTabItem.Content>
            </tabView:SfTabItem>

            <tabView:SfTabItem Title="Contacts">
                <tabView:SfTabItem.Content>
                    <Grid BackgroundColor="White" x:Name="ContactsGrid" />
                </tabView:SfTabItem.Content>
            </tabView:SfTabItem>

        </tabView:SfTabView>
    </ContentPage.Content>
</ContentPage>


Solution 1:[1]

<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:mynamespace=clr-namespace:App5.Views" 
    ...>
...
    <tabView:SfTabItem.Content>
        <mynamespace:Self_Trainig ... />
    </tabView:SfTabItem.Content>

Explanation:

  • Add an xmlns:... definition for the namespace your ContentView is in.
  • Add an element with that namespace and the class name of your ContentView.
  • ...: After the class name, you can add any needed attributes. Just like any other ContentView.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ToolmakerSteve