# 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,结构更清晰、导航更强大。
```