【发布时间】:2019-11-19 05:39:57
【问题描述】:
我无法进行简单的测试以在我的 Xamarin 表单应用程序的导航栏中显示标题。我在下面提供我的代码,基本上当我在内容页面上设置标题并将内容页面包装在导航页面中时,导航栏不会显示内容页面中的相应标题。
App.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
Current.MainPage = new NavigationPage(new Presentation.Views.SettingsDeviceUnitView());
}
}
ContentPage.cs
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SettingsDeviceUnitView : ContentPage
{
public SettingsDeviceUnitView()
{
InitializeComponent();
}
}
ContentPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="clr-namespace:GFIApp.Presentation.Controls"
mc:Ignorable="d"
x:Class="TestApp.Presentation.Views.SettingsDeviceUnitView"
BackgroundColor="{StaticResource Key=ColorPrimary}"
Title="TestTitle">
<ContentPage.Content>
<Grid>
</Grid>
</ContentPage.Content>
</ContentPage>
但我在导航栏中什么也看不到
有没有人见过这种行为或有什么建议?谢谢!
【问题讨论】:
-
你在真机上测试过吗?
-
不,我没有,只是在模拟器上。明天我将尝试开发设备。你认为这是一个模拟器的问题?它似乎可以加载其他所有内容。
-
我的猜测是,如果有意义的话,标题的 NavigationBar 颜色和 TextColor 是相同的尝试使用
BarTextColor更改它,看看是否适合您 -
@Schwagmister 如果我可以将其添加为答案并且您可以标记它,那就太好了:D
-
它说我必须等待 2 天才能标记我自己的答案 D:
标签: xamarin xamarin.forms xamarin.android