Xamarin.From ContentView 自定义标题栏

添加自定义标题栏

public partial class Main : ContentPage
{
    public Main()
    {
        InitializeComponent();
        // 添加标题栏
        NavigationPage.SetTitleView(this, new TitleView());
    }
}

 

定义标题栏

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PileShow.View.TitleView">
  <ContentView.Content>
        <StackLayout Orientation="Horizontal">
            <StackLayout HorizontalOptions="EndAndExpand">
                <Label Text="{Binding Time}" FontSize="21"/>
            </StackLayout>
        </StackLayout>
  </ContentView.Content>
</ContentView>

 

posted @ 2025-10-27 15:57  妖言惑众'  阅读(0)  评论(0)    收藏  举报