当前位置:网站首页>(03).NET MAUI实战 基础控件
(03).NET MAUI实战 基础控件
2022-06-30 03:34:00 【dotNET跨平台】
1.概要
本章将继续介绍.NET MAUI中的常用基础控件,让刚刚接触MAUI的小伙伴有写基础的认识,心里有底开发起来将得心应手。下面将列出一些常用的基础控件:
| 控件名 | 中文名称 | 说明 |
|---|---|---|
| Button | 按钮 | 与WPF中的基础用法无太大变化 |
| CheckBox | 单选框 | 与WPF中的基础用法无太大变化 |
| ListView | 列表 | 类似WPF中列表控件“ListBox” |
| ImageButton | 图片按钮 | WPF中没有该控件,通常需要开发者手动实现,MAUI中已经包含在基础控件中。 |
| Entry | 输入框 | 类似WPF中的输入框控件“TextBox” |
| TableView | 选项卡 | 类似WPF中"TabControl" |
| DisplayAlert | 消息框 | 类似WPF中“MessageBox” |
2.详细内容
(1)Button

xaml语法:
<Button Text="我是Btn" WidthRequest="200" HeightRequest="50" Command="{Binding OkCommand}" CommandParameter="{Binding}"/>(2)CheckBox
uncheck状态

check状态

xaml语法:
<CheckBox IsChecked="True"/>(3)ListView

xaml语法1:
<ListView ItemsSource="{Binding Temps}" HeightRequest="500" WidthRequest="300"/>xaml语法2:
<ListView HeightRequest="500" WidthRequest="300">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="我是listview item1" TextColor="Red"></Label>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>(4)ImageButton

xaml语法:
<ImageButton Source="/img/1.jpg" WidthRequest="200" HeightRequest="50" Command="{Binding OkCommand}" CommandParameter="{Binding}"/>(5)Entry

xaml语法:
<Entry Text="我是输入框" WidthRequest="100" HeightRequest="50"/>(6) TableView

xaml语法:
<TableView HasUnevenRows="True">
<TableView.Root>
<TableSection TextColor="Red" Title="Tab1">
//Cell里也可以放其他内容
<TextCell TextColor="Red" Text="Item1"></TextCell>
<TextCell TextColor="Red" Text="Item2" IsEnabled="False"></TextCell>
</TableSection>
<TableSection TextColor="Blue" Title="Tab2">
<TextCell TextColor="Blue" Text="Item1"></TextCell>
<TextCell TextColor="Blue" Text="Item2" Detail="test">
<TextCell.ContextActions>
<MenuItem Text="More"></MenuItem>
<MenuItem Text="Delete"></MenuItem>
</TextCell.ContextActions>
</TextCell>
</TableSection>
</TableView.Root>
</TableView>(6) DisplayAlert

C#语法:
DisplayAlert("新消息","新年快乐","ok");边栏推荐
- [personal summary] learning plan
- Reasons for MySQL master-slave database synchronization failure
- 第2章 控制结构和函数(编程题)
- 【笔记】2022.5.28 从网页获取数据并写入数据库
- What does the hyphen mean for a block in Twig like in {% block body -%}?
- 专升本高数(四)
- Global and Chinese market of bronze valves 2022-2028: Research Report on technology, participants, trends, market size and share
- ReSharper 7. Can X be used with vs2013 preview? [off] - can resharper 7 x be used with VS2013 preview? [closed]
- 4-5 count words and spaces (15 points)
- Feign 坑
猜你喜欢

MySQL performance optimization (6): read write separation

51单片机的室内环境监测系统,MQ-2烟雾传感器和DHT11温湿度传感器,原理图,C编程和仿真

QT中foreach的使用

Node-RED系列(二八):基于OPC UA节点与西门子PLC进行通讯

共124篇!墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG)

Number of students from junior college to Senior College (4)

Simple custom MVC optimization

dbt产品初体验

An article to get you started VIM

1152_ Makefile learning_ Pattern matching rules
随机推荐
X书6.89版本shield-unidbg调用方式
【作业】2022.5.28 将CSV写入数据库
Redis high concurrency distributed locks (learning summary)
【云原生】AI云开发平台——AI Model Foundry介绍(开发者可免费体验AI训练模型)
Mathematical solution of Joseph Ring
What are outer chain and inner chain?
QT中foreach的使用
Huawei interview question: divide candy
Global and Chinese markets for advanced wound care 2022-2028: Research Report on technology, participants, trends, market size and share
Version correspondence table of tensorflow, CUDA and bazel
Use of custom MVC
Arrangement of language resources of upgraded version
MySQL performance optimization (6): read write separation
1148_ Makefile learning_ Targets, variables, and wildcards in makefile
Global and Chinese market of ULTRACENTRIFUGES 2022-2028: Research Report on technology, participants, trends, market size and share
Half a year after joining the company, I was promoted to a management post
ThingsBoard教程(二三):在规则链中计算二个设备的温度差
Hash design and memory saving data structure design in redis
Realization of BFS in C language by storing adjacency matrix of graph
Installation and use of yarn