问题描述
我想在 iOS 上使用 xamarin 显示非常简单的工具栏,但我看不到显示的工具栏。
我使用此代码:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Test.MainPage">
<ContentPage.toolbaritems>
<ToolbarItem Text="Example Item"
IconImageSource="https://img.icons8.com/cute-clipart/64/000000/menu.png"
Order="Primary"
Priority="0" />
</ContentPage.toolbaritems>
</ContentPage>
需要更改什么才能看到工具栏?
解决方法
您是否将您的页面放在 NavigationPage 中?默认情况下 ContentPage 没有导航栏(工具栏),您必须将您的页面放在 NavigationPage 中,之后导航栏将显示其功能。 看看这里:Xamarin.Forms Navigation
所以我认为你应该做这样的事情
public App ()
{
MainPage = new NavigationPage (new MainPage());
}