初看,需要继续
- AsyncLazy<>
- 源生成器
- 自定义ServiceCollection
烂笔头
安卓不支持KeyValuePair<>的json反序列化
-
2026.3.24
- 使WebView的输入框不被软键盘覆盖
App()Current!.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>() .UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize); - Toast生效
.UseMauiCommunityToolkit(options => { options.SetShouldEnableSnackbarOnWindows(true); })
- 使WebView的输入框不被软键盘覆盖
-
2026.3.21
- Shell
- Title windows没有Title的时候,他顶上
- IconImageSource似乎不起作用
- 可以包含一个TabBar,可以省略
- TabBar:包含一个或者多个Tab
- Tab
- Title 就是菜单显示项
- 可以包含一个或者多个ShellContent,若多个就是子菜单
- ShellContent
- Title 若Page没有设置Title,则显示该Title。若都没有则不显示 NavBar..
- ContentTemplate="{DataTemplate local:SomePage}"
- Route="SomeRoute" GoToAsync时调用
-
2026.2.22
今天有点2的,安卓错误 这可能是由于项目的文件名或路径中包含非 ASCII 字符,就是不能由中文字符等等等等 -
2026.2.10
- [Maui] FireAndForgetSafeAsync 前几天已经魔改完成。从静态类为了能注入日志功能,改成非静态类;然后发现Maui写了好多静态属性,可以直接用 IViewHandler 调用注入的日志,又改回静态类。
public static Page CurrentPage { get => Application.Current!.Windows[0].Page!; }
public static INavigation Navigation { get => CurrentPage.Navigation; }
public static IViewHandler Handler { get => CurrentPage.Handler!; }
- 动态加载程序集时,无法解析XAML中引用的本地Page、View、类(如DataTemplateSelector)时,需要在项目属性加入现在的代码。
故UI相关的类库都需要此属性。
<PropertyGroup>
<MauiXamlInflator>SourceGen</MauiXamlInflator>
</PropertyGroup>
好吧,增加了上面的代码还是无法解决DataTemplateSelector的问题。
问了deepseek,deepseek答对了,原因是动态加载的程序集和主程序集不在同一个 AssemblyLoadContext 中,导致类型解析失败。
AssemblyLoadContext.Default.Load...
** 2026.2.1 **
- [Maui] ViewContent中的CollectionView设置Button Command的写法
2月2日的时候不小心写成Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ExecuteCommand}",当ItemsSource变化后,标题栏里面的按钮失效!!!
<?xml version="1.0" encoding="utf-8" ?>
<!--增加x:Name...-->
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Name="TitleView"
xmlns:viewmodels="clr-namespace:MauiSsm"
x:Class="MauiSsm.UI.Default.VTitle">
<CollectionView ItemsSource="{Binding Pages}">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Button Text="{Binding}" Margin="0,0,10,0"
Command="{Binding Source={x:Reference TitleView},Path=BindingContext.ExeCommand}"
CommandParameter="{Binding}"></Button>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentView>
- [Maui] Label Click,所谓 手势
<Label
Text="{Binding InitMessage}"
VerticalOptions="Center"
HorizontalOptions="Center" >
<Label.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Command="{Binding AlertCommand}"></TapGestureRecognizer>
</Label.GestureRecognizers>
</Label>
- [C#]is或者is not
int i=0;
if(i==1 || i==10 || i==15)
{
}
if(i is (1 or 10 or 15)
if(i!=1 && i!=10 && i!=15)
{
}
if(i is not (1 or 10 or 15)
{
}
浙公网安备 33010602011771号