# xaml 页面控件 #### 通用属性(所有页面都可用)
属性名说明
AutomationId自动化测试标识
StyleClass样式类
Resources资源集合(样式、颜色等)
BindingContext数据上下文
ToolbarItems工具栏按钮集合
Visual视觉样式(如 Material)
FlowDirection布局方向(LTR/RTL)
IsBusy忙碌状态
InputTransparent是否响应输入
Opacity透明度
IsEnabled是否可用
IsVisible是否可见
Margin外边距
WidthRequest/HeightRequest宽高请求
MinimumWidthRequest/MinimumHeightRequest最小宽高
MaximumWidthRequest/MaximumHeightRequest最大宽高
AnchorX/AnchorY锚点
Rotation/RotationX/RotationY旋转
Scale缩放
TranslationX/TranslationY平移
#### ContentPage 所有常用属性及注释 ``` BackgroundColor="AliceBlue" Padding="20,40,20,20" IconImageSource="icon.png" FlowDirection="LeftToRight" IsBusy="False" Visual="Material" AutomationId="ContentPage1" StyleClass="mainPage" Shell.TabBarIsVisible="True" Shell.NavBarIsVisible="True" Shell.BackgroundColor="LightGray" Shell.TitleColor="DarkBlue" Shell.DisabledColor="Gray" Shell.TabBarBackgroundColor="White" Shell.TabBarTitleColor="Black" Shell.TabBarUnselectedColor="LightGray" Shell.TabBarForegroundColor="DodgerBlue" Shell.TabBarDisabledColor="Gray" Shell.TabBarShadowColor="LightGray" > ``` #### FlyoutPage 所有常用属性及注释 ``` IsPresented="False" FlyoutIcon="menu.png" FlyoutBackgroundColor="LightGray" FlyoutWidth="300" > FlyoutHeader:菜单头部内容 FlyoutFooter:菜单底部内容 ``` #### NavigationPage 所有常用属性及注释 ``` BarTextColor="White" TitleIconImageSource="navicon.png" Shell.NavBarIsVisible="True" Shell.NavBarHasShadow="True" Shell.NavBarBackgroundColor="LightBlue" Shell.NavBarTitleColor="DarkBlue" Shell.NavBarDisabledColor="Gray" Shell.NavBarForegroundColor="DodgerBlue" Shell.NavBarShadowColor="LightGray" > HasNavigationBar(C# 设置):是否显示导航栏 ``` #### TabbedPage 所有常用属性及注释 ``` BarTextColor="Gray" SelectedTabColor="DodgerBlue" UnselectedTabColor="LightGray" Shell.TabBarIsVisible="True" Shell.TabBarBackgroundColor="White" Shell.TabBarTitleColor="Black" Shell.TabBarUnselectedColor="LightGray" Shell.TabBarForegroundColor="DodgerBlue" Shell.TabBarDisabledColor="Gray" Shell.TabBarShadowColor="LightGray" > 其它可用属性: CurrentPage:当前选中页面(C# 访问) 每个子页面可自定义 Title、IconImageSource ``` #### Shell 介绍及与页面的关系 ``` Shell 是 .NET MAUI 推荐的导航和应用结构容器,支持 Flyout(侧边栏)、TabBar(底部标签)、Stack(分层导航)等多种页面结构组合。 Shell 与四大页面的关系 Shell 可以包含 FlyoutPage、TabbedPage、NavigationPage、ContentPage。 Shell 通过 标签定义导航结构,页面通过 Route 路由注册。 Shell 属性(如 Shell.TabBarIsVisible)只有在 Shell 结构下才生效。 Shell 支持 URI 路由导航、全局样式、统一导航栏/TabBar配置。 ``` #### **要点:** ``` Shell 可组合 Flyout(侧边栏)、TabBar(底部标签)、Stack(分层导航)。 Shell 支持全局样式和导航栏/TabBar统一配置。 页面可通过 Shell 属性自定义在 Shell 下的表现。 推荐新项目优先使用 Shell,结构更清晰、导航更强大。 ```