当前位置:网站首页>Maui introductory tutorial series (5.xaml and page introduction)
Maui introductory tutorial series (5.xaml and page introduction)
2022-07-04 04:49:00 【Dotnet cross platform】
Preface
As a Microsoft UI frame , except Winform outside , Most are created by XAML File way to write front-end pages , Although you can also pass C# Code to write your user interface , And Xamarin.Forms identical , stay MAUI Write on XAML Is declared in the same way , The underlying part is reconstructed, but most of it inherits the original pattern .
Compared with other XAML Declarative UI frame , Such as :WPF、UWP、UnoPlatform、Avalonia Their declaration methods are different .
XAML Introduce
stay MAUI in , Create a XAML page , It mainly consists of two parts : XAML file +CS file .
XAML
<ContentPage
x:Class="MauiApp5.MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<!-- -->
</ContentPage>x:Class : representative XAML The file points to partial class , XAML be responsible for UI Design , CS Class is responsible for writing business logic .
xmlns : full name xamlnamespace, The representative declared that XAML Namespace
xmlns:x="..." : Aliased naming xml Space , The objects under this namespace can be accessed through aliases ( Accessible )
problem 1: What is the difference between a namespace with an alias and a namespace without an alias ?
First , For one XAML In terms of documents , Only one namespace without alias can exist , In this way, you can access the objects under the namespace without alias , By default , We can use various... Provided by the framework UI object , This is the default , We don't need to show that we can access these objects through aliases , For our customized namespace , Can be accessed by alias .
Access objects under the default namespace
<Grid>
<StackLayout>
<Button/>
<Label/>
<Image/>
</StackLayout>
</Grid>Declare an alias to access the object
<m:ContentPage
x:Class="MauiApp5.MainPage"
xmlns:m="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<m:Grid>
<m:StackLayout>
<m:Button/>
<m:Label/>
<m:Image/>
</m:StackLayout>
</m:Grid>
</m:ContentPage>problem 2: x:Class What are the requirements of some classes pointed to ?
CS partial Class and XAML It's the same class , Just responsible for different work .XAML Usually more concise and readable than equivalent code , and C# Code can handle complex conditional judgments 、 Logical processing . Make sure , This part of the class needs and XAML The base class of is the same .
CS
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}Page introduction
MAUI Frame built in 4 Page types , To meet different application scenarios , as follows :
ContentPage
Content page , Usually used to define the visual layout of a page 、 Nested display sub elements, etcFlyoutPage
It contains a floating control page of display items and a detailed information page , It encapsulates the functions for side navigation and operationNavigationPage
Provides pages for forward and backward navigation

TabbedPage
Provide tab switching pages , Common in mobile devices .
These page types , They are all directly or indirectly inherited from Page class , Each realizes some functions .
summary
This paper mainly introduces MAUI in XAML File class description and several page types provided , The following article will mainly introduce XAML Specific layout and methods in .
边栏推荐
- Acwing game 58
- How do good test / development programmers practice? Where to go
- MySQL JDBC programming
- Change the background color of Kivy tutorial (tutorial includes source code)
- 最长递增子序列问题(你真的会了吗)
- Annex VI: defense work briefing docx
- Developing mqtt access program under QT
- 分布式CAP理论
- A beautiful API document generation tool
- Intersection traffic priority, illustration of intersection traffic rules
猜你喜欢
![[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise](/img/f2/3b95f53d67cd1d1979163910dbeeb8.png)
[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise

Redis: order collection Zset type data operation command

DCDC电源电流定义

分布式CAP理论

深入解析结构化异常处理(SEH) - by Matt Pietrek
![[wechat applet] good looking carousel map component](/img/66/4ae6a72fff419c7ed1ca015eb94c03.jpg)
[wechat applet] good looking carousel map component

Deep parsing structured exception handling (SEH) - by Matt Pietrek

Kivy教程之 更改背景颜色(教程含源码)

rac删除损坏的磁盘组

Redis: hash type data operation command
随机推荐
Rhcsa 03 - Basic permissions for documents
MySQL JDBC programming
MIN_ RTO dialog
郑州正清园文化传播有限公司:针对小企业的7种营销技巧
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
测试 CS4344 立体声DA转换器
更优雅地远程操作服务器:Paramiko库的实践
Unity Resource path
【愚公系列】2022年7月 Go教学课程 001-Go语言前提简介
6-5 vulnerability exploitation SSH weak password cracking and utilization
FT2000+下LPC中断绑核使用说明
The five pictures tell you: why is there such a big gap between people in the workplace?
Developing mqtt access program under QT
Longest increasing subsequence problem (do you really know it)
【安全攻防】序列化与反序列,你了解多少?
Experience sharing of epidemic telecommuting | community essay solicitation
How to view installed r packages in R language
Drozer tool
ADB tools
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon