xaml - 如何使用 xamarin.forms 中的 xaml 在主详细信息页面中显示页面标题?

标签 xaml xamarin.forms

我想使用 xaml 在主详细信息页面中显示页面标题。我尝试在 MasterDetailPageMasterDetailPage.Master 内添加 x:Namex:Title 属性MasterDetailPage.Details 标记。但这些都不起作用。这是 xaml:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local="clr-namespace:MSCommunity_Xamarin"
         xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
         prism:ViewModelLocator.AutowireViewModel="True"
         x:Class="PrismUnityApp3.Views.MainPage"
         x:Name="Page title">

<MasterDetailPage.Master>
</MasterDetailPage.Master>

<MasterDetailPage.Detail>
</MasterDetailPage.Detail>

最佳答案

仅对 NavigationPage 中嵌入的页面显示页面标题,并且正在查找的属性是 Title(不是 x:Title,不是 x:Name)。

将 MDP 嵌入 NP 没有多大意义。通常的模式是在 NavigationPage 中设置一堆 ContentPage(设置了 Title)作为 Detail MasterDetailPage 的。 MDP 是您的 Application.MainPage

关于xaml - 如何使用 xamarin.forms 中的 xaml 在主详细信息页面中显示页面标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41973919/

相关文章:

c# - XAML 和 IValueConverter - 首先转换为复杂对象,然后绑定(bind)到结果的属性路径

wpf - 在这种情况下,为什么 ActualWidth 和 ActualHeight 为 0.0?

c# - 将控件颜色更改为默认值

c# - Xamarin Master Detail 句柄泛型

c# - 如何删除 00 :00:00 from DateTime property

android - 如何在 Xamarin.Forms 中显示 "up"/"back"按钮?

c# - 如何在 ItemsSource 绑定(bind)中获取当前 'item'

c# - 为什么我在 Visual Studio 的对象浏览器中找不到 System.Windows.Controls 命名空间?

c# - 使用 Xamarin.Forms 中的 View 模型属性绑定(bind)到 StaticResource?

c# - 删除 xamarin 表单布局中的额外空间