xaml - 在 xamarin 中更改导航栏标题位置

标签 xaml xamarin xamarin.forms portable-class-library

如何在 Xamarin.Forms 中更改导航栏 title 的位置。

我默认得到的是:

enter image description here

我想要的是:

enter image description here

我如何在 Xamarin.Forms 中执行此操作?

最佳答案

如果您使用的是基于 Shell 的 Xamarin.forms 应用那么您可以使用 Shell.TitleView 轻松实现此目的,定义您的标题内容,绑定(bind)它,甚至根据您的喜好设置样式。

在您的 ContentPage 中:

<Shell.TitleView>
    <Label Text="Your Title" HorizontalTextAlignment="Center" HorizontalOptions="CenterAndExpand"/>
</Shell.TitleView>

您将避免使用自定义渲染器。

此外,如果您需要应用一些特殊的平台相关调整,您可以使用 OnPlatform .

关于xaml - 在 xamarin 中更改导航栏标题位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42556682/

相关文章:

Xamarin iOS 图像在网格内重叠

c# - 如何使用 OnRender 自定义 TextBlock

c# - LongListSelector 停止滚动并卡住

xaml - 如何在 Visual Studio 2012 中为选定的 XAML 节点设置背景颜色

c# - 调用 Device.RuntimePlatform 导致运行时异常

ios - 在 Release模式或临时模式下编译时出错,Xamarin Forms iOS,

visual-studio - Visual Studio 2015 社区 + Resharper 9 : 2 pop-up lists show for intellisense

xamarin - 更新到 XCode 8.3.1 后,Intellisense 在最新的稳定版 Xamarin iOS 中被破坏

c# - Xcode Cocoa - 从 NSTableView 拖放到 Finder

c# - 来自不同类的 UITextField null