当前位置:网站首页>(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");边栏推荐
- Installation and use of yarn
- QT中foreach的使用
- From 2500 a month, no one wants to go to the programming road of the technical director of a large factory | my ten years
- 华为云原生——数据开发与DataFactory
- [practical skills] how to write agile development documents
- C#【高级篇】 C# 多线程
- Mysql性能优化(6):读写分离
- Redis is used in Windows system
- Linked list: insert a node in the head
- How does the trading platform for speculation in spot gold ensure capital security?
猜你喜欢

TiDB 6.0:讓 TSO 更高效丨TiDB Book Rush

【笔记】2022.5.23 MySQL

C#【高级篇】 C# 多线程
![[punch in - Blue Bridge Cup] day 2 --- format output format, ASCII](/img/b2/0059659867e867a32b8e7cef567c8b.jpg)
[punch in - Blue Bridge Cup] day 2 --- format output format, ASCII
![[Note] ab Test and Variance Analysis](/img/f2/58369a99514d37d5af335a61d0911f.jpg)
[Note] ab Test and Variance Analysis

HOOK Native API

hudi记录

Laravel9 installation locale

专升本高数(四)
![[punch in - Blue Bridge Cup] day 4--------- split ('') cannot be used. There is a space after the last number of test cases. Split ()](/img/00/3793a236ee37085cb47dbfa1f0dbff.jpg)
[punch in - Blue Bridge Cup] day 4--------- split ('') cannot be used. There is a space after the last number of test cases. Split ()
随机推荐
Personal PC installation software
Is the largest layoff and salary cut on the internet coming?
Global and Chinese market of bulk acoustic wave devices 2022-2028: Research Report on technology, participants, trends, market size and share
[0x0] 校长留的开放问题作业
Installation and use of yarn
Use common fileUpload to upload files
WPF initialized event in The reason why binding is not triggered in CS
【个人总结】学习计划
Simple custom MVC optimization
Stc89c52/90c516rd/89c516rd DHT11 temperature and humidity sensor drive code
Dripping backward (II)
11: I came out at 11:04 after the interview. What I asked was really too
The next change direction of database - cloud native database
Knowledge points of 2022 system integration project management engineer examination: software quality assurance and quality evaluation
Openssl3.0 learning 22 provider decoder
An article to get you started VIM
laravel9本地安裝
Redis is used in Windows system
产品思维 | 无人机快递的未来值得期待吗?
Tidb 6.0: making Tso more efficient tidb Book rush