簡體   English   中英

如何在 ContentPage 中顯示 ContentView

[英]How can I display a ContentView in a ContentPage

我創建了一個 sftabView,每個 SfTabItem 都有一個 ContentView,所以我創建了另一個 View 來在這個 ContentView 中顯示它。 所以問題是如何做到這一點? 這是我想在 ContentPage 中顯示的 ContentView

<?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>

這是我的 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>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:mynamespace=clr-namespace:App5.Views" 
    ...>
...
    <tabView:SfTabItem.Content>
        <mynamespace:Self_Trainig ... />
    </tabView:SfTabItem.Content>

解釋:

  • 為 ContentView 所在的命名空間添加xmlns:...定義。
  • 使用該命名空間和 ContentView 的類名添加一個元素。
  • ... :在類名之后,您可以添加任何需要的屬性。 就像任何其他 ContentView 一樣。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM