MAUI导航栏-Android
底部导航栏-TabBar,示例:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="Test.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Test"
Shell.FlyoutBehavior="Disabled">
<TabBar>
<ShellContent
Title="笔记"
ContentTemplate="{DataTemplate local:MyPage.Views.NotePage}"
Icon="icon_notes" />
<ShellContent
Title="关于"
ContentTemplate="{DataTemplate local:MyPage.Views.AboutPage}"
Icon="icon_about" />
</TabBar>
</Shell>
顶部导航栏-ContentPage.ToolbarItems,示例:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Test.MyPage.Models"
x:Class="Test.MyPage.Views.AllNotesPage"
Title="笔记列表">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Add" Clicked="Add_Clicked" IconImageSource="{FontImage Glyph='+', Color=White, Size=22}" />
</ContentPage.ToolbarItems>
<!-- 在列表中显示注释 -->
<CollectionView x:Name="notesCollection"
ItemsSource="{Binding Notes}"
Margin="20"
SelectionMode="Single"
SelectionChanged="notesCollection_SelectionChanged">
<!-- 指定项目集合的布局方式 -->
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="10" />
</CollectionView.ItemsLayout>
<!-- 定义列表中每个项目的外观 -->
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Label Text="{Binding Text}" FontSize="22"/>
<Label Text="{Binding Date}" FontSize="14" TextColor="Silver"/>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage>
本文来自博客园,作者:꧁执笔小白꧂,转载请注明原文链接:https://www.cnblogs.com/qq2806933146xiaobai/p/16709717.html
分类:
.Net-MAUI
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下