C# Xamarin未找到';的属性、可绑定属性或事件;工具栏项目';

C# Xamarin未找到';的属性、可绑定属性或事件;工具栏项目';,c#,xaml,xamarin,xamarin.forms,C#,Xaml,Xamarin,Xamarin.forms,我试图做的是将工具栏添加到内容页 在StackLayout 更多信息。如果我把上面的代码放在与topStackLayout相同的位置,工具栏就不会出现 我遇到了一个错误,在其他任何地方都找不到同样的错误 这是我的xaml文件内容 这就是错误所在 No property, bindable property, or event found for 'ToolbarItems' 以及全部错误 /Users/UZU/Google Drive/Apps/EodiRoad/EodiRoadXam

我试图做的是将工具栏添加到内容页

StackLayout


更多信息。如果我把上面的代码放在与top
StackLayout
相同的位置,工具栏就不会出现

我遇到了一个错误,在其他任何地方都找不到同样的错误

这是我的xaml文件内容


这就是错误所在

No property, bindable property, or event found for 'ToolbarItems'
以及全部错误

/Users/UZU/Google Drive/Apps/EodiRoad/EodiRoadXamarin/EodiRoad/EodiRoad/EodiRoad.Views.SocialPage.xaml(5,5): Error: Position 13:5. No property, bindable property, or event found for 'ToolbarItems' (EodiRoad)
我做错了什么?那个错误是怎么回事,怎么纠正?!
我相信你们。

你们需要在
堆栈布局之外添加
工具栏项目
,试试以下方法:

<ContentPage 
    xmlns:ic="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="EodiRoad.SocialPage">
    <ContentPage.ToolbarItems>
        <ToolbarItem Icon="plus.png"/>
    </ContentPage.ToolbarItems>
    <StackLayout>
        <!-- Your Content -->
    </StackLayout>
</ContentPage>

这段代码


可能意味着两件事,具体取决于上下文:

  • 让我们设置此ContentPage的ToolbarItems属性(或ToolbarItemsProperty BindableProperty)(如果父节点是ContentPage,或
  • 让我们将附加的BindableProperty ContentPage.ToolbarItemsProperty设置为当前BindableObject
  • 当您在
    堆栈布局中使用此属性时,它被解释为第二个属性,但这样的属性不存在!因此它失败

    把它直接放在
    内容页面
    中,它会像一个符咒一样工作

    
    

    关于工具栏项目未显示,根据您运行的平台,可能需要将内容页打包到导航页中。

    哦!感谢您的精彩解释。我使用的是选项卡页内的内容页。因此,在这种情况下,我无法显示工具栏吗?