勇哥注:
下面开启新框架的第一个程序。我们不用系统自动生成的。自己编辑一个。
MainPage.xaml 代码:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp2.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="25"
Padding="30"
VerticalOptions="Center">
<Label x:Name="lab1" />
<Button Text="click me" Clicked="Button_Clicked"/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
MainPage.xaml.cs代码:
namespace MauiApp2
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
this.lab1.Text = "Hello world";
}
}
}
在windows machine下的效果:
注意:
你只能通过vs来执行,无法直接运行bin目录下的exe。因为它必须安装布署后才能运行的。
详细见下面的说明:
Maui Blazor windows程序无法通过双击 bin 文件夹中的 exe打开程序的解决办法
https://blog.csdn.net/sd2208464/article/details/127423927
最后记录几个资源 :
nuget中国地区镜像
https://nuget.cdn.azure.cn/v3/index.json
用上国内镜像,从此使用nuget的速度要快上几个量级。
设置方法如下:
VisualStudio神级插件Resharper使用技巧基础入门到骨灰玩家全教程+性能优化
https://zhuanlan.zhihu.com/p/262152358
Resharper安装与使用
https://www.cnblogs.com/lihuali/p/6321891.html
微软官方姗姗来迟的MVVM工具包
https://learn.microsoft.com/zh-cn/dotnet/communitytoolkit/mvvm/

