.net MAUI Shell:如何将可点击的项目添加到TabBar或FlyoutItem?

k4ymrczo  于 2022-11-19  发布在  .NET
关注(0)|答案(1)|浏览(195)

我需要在TabBar(或FlyoutItem)中添加一个类似于shell中MenuItem的项目(只是没有ContentPage的按钮)。

<FlyoutItem>
        <ShellContent Route="kitties" Title="Kitties" Icon="cat.png" ContentTemplate="{DataTemplate views:GeneralAnimalPage}"/>

        <!-- something like this -->
        <SomeItem Title="Press me"  Click="Click_Handler"/>
        
        <!-- or this -->
        <Tab Title="Press me" Command="{Binding MyCommand}"/>

        <!-- or even this: no contenttemplate, just routing! -->
        <ShellContent Title="Press me"  Route="myroutepage1"/>

</FlyoutItem>

领先:我将需要在codebehind中以编程方式添加它,并且条目必须在底部栏中。

gijlo24d

gijlo24d1#

替代但实际有效的方法:
您可以使用BindableLayout和RadioButton编写自己的TabBar。
好的开始:https://dev.to/davidortinau/making-a-tabbar-or-segmentedcontrol-in-net-maui-54ha

相关问题