(03).NET MAUI实战 基础控件
2023-06-13 09:15:42 时间
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");
相关文章
- ASP.NET MVC4开发指南_vue mvc
- .NET 7正式发布
- ASP.NET Core技术--Identity Server 4 基础
- 使用MD5WithRSA来签名和验签(.NET)详解编程语言
- net掌握Linux环境下的.NET开发(linuxdot)
- C#/.NET BCL:基础类库
- .net利用MSSQL连接ASP.NET的办法探索(mssql 连接asp)
- .Net搭配Redis解决高性能应用问题(.net redis)
- Net与Oracle构建连接的数据价值(.net 链oracle)
- CMySQL与NET技术融会贯通(c mysql .net)
- 数据库使用net实现MYSQL数据库创建(.net 创建mysql)
- 剑指临床试验的设计难题!达摩院提出新模型EBM-Net,比最强基线模型准确率高9.6%
- .NET数据库连接池
- ASP.NET下对cookies的操作实现代码
- 使用.NET中的Action及Func泛型委托深入剖析
- .NET线程基础的使用介绍
- .net基础收集汇总
- asp.net解决上传4M文件限制
- asp.net读取excel中的数据并绑定在gridview
- asp.net传多个值到其它页面的具体实现
- asp.net显示自己的网页图标的几种方式