maui-shell 相关问题


识别.NET MAUI 应用程序中用户所在的页面

如何在 .NET MAUI shell 应用程序中识别用户所在的页面? 为了提供更多背景信息,这就是我正在尝试做的事情: 我的 .NET MAUI 应用程序(使用 Shell)有相当多的页面,其中一些...


如何在 iOS 上的 .NET MAUI 中增加 TabBar 菜单项的字体大小?

我正在使用 .NET MAUI Shell Tabbar,并且我正在尝试专门在 iOS 平台上增加 TabBar 菜单项的字体大小。您能否为此提供示例代码片段? 我很感激任何


.NET MAUI 中的 Shell 背景渐变

知道如何为 Shell 提供渐变背景吗? 我尝试在 Shell 背景上定义 LinearGradientBrush 但这不起作用。 知道如何为 Shell 提供渐变背景吗? 我尝试在 Shell 背景上定义 LinearGradientBrush,但这不起作用。 <?xml version="1.0" encoding="UTF-8" ?> <Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <Shell.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </Shell.Background> <FlyoutItem FlyoutDisplayOptions="AsMultipleItems"> <!-- FlyoutItem contents here --> </FlyoutItem> </Shell> 我已经确认这是为 Shell.Background 设置渐变时的已知问题,请参阅 Shell.Background - Gradient does not work #10445,您可以按照该线程进行操作。 幸运的是,您可以单独设置渐变背景。如果您有“外壳”弹出窗口,则可以为“外壳”弹出项目设置渐变背景: <Shell.FlyoutBackground> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </Shell.FlyoutBackground> 另外,如果要将 ShellContent 背景设置为渐变背景,可以将渐变背景添加到 ContentPage 的背景属性中。 <ContentPage.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </ContentPage.Background> 希望这有帮助!


.NET MAUI:自定义Shell TitleView并绑定到当前页面标题

我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: 我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: <?xml version="1.0" encoding="UTF-8" ?> <Shell x:Class="MyNamespace.App.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyNamespace.App" xmlns:pages="clr-namespace:MyNamespace.App.Pages" BindingContext="{x:Static local:MainView.Instance}" Shell.FlyoutBehavior="{Binding ShellFlyoutType}" x:Name="shellMain"> <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" Text="{Binding Path=CurrentPage.Title, Mode=OneWay}" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> <ShellContent Title=" Login" ContentTemplate="{DataTemplate local:MainPage}" Route="login" FlyoutItemIsVisible="False" /> <ShellContent Title="Dashboard" ContentTemplate="{DataTemplate pages:DashboardPage}" Route="dashboard" /> </Shell> 我无法绑定当前页面标题。 我的 AppShell.xaml Shell 声明如下 <Shell ... x:Name="shellMain"> 作为替代方案,您可以在 OnNaviged 方法中设置 titleview : 在 AppShell.xaml 中,定义标签的名称 <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" x:Name="mylabel" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> 在AppShell.xaml.cs中,重写OnNaviged方法,获取当前项目 protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); var shellItem = Shell.Current?.CurrentItem; string title = shellItem?.Title; int iterationCount = 0; while (shellItem != null && title == null) { title = shellItem.Title; shellItem = shellItem.CurrentItem; if (iterationCount > 10) break; // max nesting reached iterationCount++; } myLabel.Text = title; } 希望它对你有用。 我正在尝试同样的方法来修改 TitleView 的外观。它可以在 iOS 上运行,尽管那里还有另一个错误。但在 Android 上我遇到了同样的问题。在前进导航中,它会更新标题,但当您按后退按钮时,标题不会更新。我已经打开了一个问题并添加了一个存储库。 https://github.com/dotnet/maui/issues/12416#issuecomment-1372627514 还有其他方法可以修改TitleView的外观吗? 我使用视图模型开发了这个解决方法,主要不是为了提供 MVVM 解决方案,而是因为其他建议的答案对我不起作用。 (我怀疑 Liqun Shen 2 月 15 日针对他自己的问题的评论中的建议会起作用。但我没有注意到这一点,直到我自己修复)。 当前页面的标题保存在可由 shell 的视图模型和每个内容页面的视图模型访问的类中: public class ServiceHelper { private static ServiceHelper? _default; public static ServiceHelper Default => _default ??= new ServiceHelper(); internal string CurrentPageTitle { get; set; } = string.Empty; } shell 中每个内容页面的视图模型提供其页面标题。为了促进这一点,大部分工作都是由基本视图模型完成的,它们都是从该模型派生而来的: public abstract class ViewModelBase(string title) : ObservableObject { private ServiceHelper? _serviceHelper; public string Title { get; } = title; internal ServiceHelper ServiceHelper { get => _serviceHelper ??= ServiceHelper.Default; set => _serviceHelper = value; // For unit testing. } public virtual void OnAppearing() { ServiceHelper.CurrentPageTitle = Title; } } 每个 shell 内容页面视图模型只需要让其基础视图模型知道它的标题: public class LocationsViewModel : ViewModelBase { public LocationsViewModel() : base("Locations") { } } 每个 shell 内容页面都需要在其视图模型中触发所需的事件响应方法: public partial class LocationsPage : ContentPage { private LocationsViewModel? _viewModel; public LocationsPage() { InitializeComponent(); } private LocationsViewModel ViewModel => _viewModel ??= (LocationsViewModel)BindingContext; protected override void OnAppearing() { base.OnAppearing(); ViewModel.OnAppearing(); } } Shell 的视图模型为标题栏提供当前页面的标题: public class AppShellViewModel() : ViewModelBase(Global.ApplicationTitle) { private string _currentPageTitle = string.Empty; public string CurrentPageTitle { get => _currentPageTitle; set { _currentPageTitle = value; OnPropertyChanged(); } } public void OnNavigated() { CurrentPageTitle = ServiceHelper.CurrentPageTitle; } } Shell 需要在其视图模型中触发所需的事件响应方法: public partial class AppShell : Shell { private AppShellViewModel? _viewModel; public AppShell() { InitializeComponent(); } private AppShellViewModel ViewModel => _viewModel ??= (AppShellViewModel)BindingContext; protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); ViewModel.OnNavigated(); } } 最后,Shell 的 XAML 在标题栏/导航栏上显示由 Shell 视图模型提供的当前页面的标题: <Shell.TitleView> <HorizontalStackLayout VerticalOptions="Fill"> <Image Source="falcon_svg_repo_com.png" HeightRequest="50"/> <Label x:Name="CurrentPageTitleLabel" Text="{Binding CurrentPageTitle}" FontSize="24" Margin="10,0" VerticalTextAlignment="Center"/> </HorizontalStackLayout> </Shell.TitleView>


Microsoft MAUI:如何在 MAUI 中创建在新窗口中打开的报告?

如何在 MAUI 中创建在新窗口中打开的动态报告?


如何在MAUI iOS中使用1x、2x和3x .png图像?

我知道我们必须使用 .svg 图像格式而不是 1x,2x,3x .png 图像格式,MAUI 会处理它,但我目前正在将现有的 Xamarin Forms 应用程序迁移到 MAUI,并且很难转换.. .


是否可以在 Google Cloud Shell 中使用 Jupyter Notebook?

我尝试过的: 启动 Google Cloud shell 须藤 pip 安装 jupyter jupyter 笔记本 --generate-config 将以下内容添加到 ~/.jupyter/jupyter_notebook_config.py c.NotebookApp.ip = 'localhost' c.


.NET MAUI - 为什么推送通知在发布后无法正常工作?

因此,我有一个专门针对 Android 的 .NET MAUI 移动应用程序,它已使用 Intent 过滤器通过 OnMessageReceived() 方法和 OnNewToken() 实现了推送通知,并...


Networkx 中 K-shell 最内核的节点

我想在Python中使用NetworkX获取k-shell算法最内核对应最高度数的节点。我尝试使用以下代码获取节点,但我遇到了...


Netrw 与终端集成

据我所知,使用 netrw 导航目录比在 shell 内部导航要容易得多。 因此,我正在尝试将 netrw 与 shell 集成,到目前为止我所拥有的很简单......


MAUI WebView 控件和 CORS

尝试使用 WebView 控件编写 MAUI 应用程序,以便我可以教学生如何解决复杂的数学问题。我选择使用 MathML,因为它支持大多数数学符号以包含自动调整...


MAUI 中切换风格问题

我正在我的 MAUI 项目上使用开关。我在 Android 设备 10 和 11 上发现了样式问题,但在 Android 12 上,不存在样式问题。 以下是 Android 10 和 Android 11 的屏幕截图。 贝尔...


使用shell中的变量将密码传递给mysql_config_editor

我的密码存储在变量 $db_pwd 中,我想在 shell 脚本中将其传递给 mysql_config_editor。我无法使用配置文件或 db_pwd 环境变量。 我正在做这个


我在安装 pyspark 时遇到错误,如何修复它?

我想安装并练习pyspark。但是在安装和进入 pyspark-shell 过程中,出现以下错误。 C:\Windows\System32>spark-shell 将默认日志级别设置为“WARN”。 至


Control Maps Net Maui (net 8.0) for Windows

我正在使用 net 8.0,我想使用 Maui.Controls.Map。 MauiProgram.cs 中的代码是: 公共静态 MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuild...


在Shell脚本中获取进程的PID

我正在编写一个shell脚本,我想获取一个名为“ABCD”的进程的PID。我所做的是: process_id=`/bin/ps -fu $USER|grep "ABCD"|awk '{print $2}'` 这获取了两个进程的PID...


无法从 tmux 中的 `run-shell` 创建新会话

我有这个+x脚本 〜/ bin / tmux-test.sh: #!/usr/bin/bash tmux 新w 在我的 .tmux.conf 中: bind -n M-g run-shell `~/bin/tmux-test.sh` 有用... ...但是如果我将 tmux neww 更改为 tmux new (对于 cre...


如何获取应用程序的屏幕空间或 MAUI 中顶部和底部栏的高度?

我在计算某些项目的位置时遇到问题,以及它们是否在 MAUI 的屏幕上可见,使用如下函数 public Point GetScreenCoords(VisualElement视图) { var 结果 = 新...


如何在launch.json中设置VS Code调试时使用的shell?

在我的 VS Code Node.js 项目的 launch.json 配置中,我尝试将 shell 设置为 cmd.exe 而不是默认值。那可能吗? 我知道我可以通过terminal.integrated.defaultPr进行全局设置...


MAUI 8 - 如何更改弹出背景叠加颜色?

使用 MAUI 7.0,下一个代码允许更改弹出背景叠加颜色,但该代码不适用于 MAUI 8.0 使用 MAUI 7.0,下一个代码允许更改弹出窗口背景覆盖颜色,但该代码不适用于 MAUI 8.0 <maui:MauiWinUIApplication x:Class="TestMaui8.WinUI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:maui="using:Microsoft.Maui" xmlns:local="using:TestMaui8.WinUI"> <maui:MauiWinUIApplication.Resources> <Color x:Key="SystemAltMediumColor">Transparent</Color> <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogBackgroundThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <StaticResource x:Key="ContentDialogBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <StaticResource x:Key="PopupLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <SolidColorBrush x:Key="SliderBorderBrush" Color="#1A73E8" /> <Style TargetType="Slider"> <Setter Property="BorderBrush" Value="{StaticResource SliderBorderBrush}"/> </Style> </maui:MauiWinUIApplication.Resources> </maui:MauiWinUIApplication> 有人知道为什么它不起作用以及如何修复它吗? 更新添加一些图片 CommunityToolkit Popup 没有 Overlay color 功能。您可以在 CommunityToolkit GitHub 页面上提出功能请求。 是的,您发布的上述代码曾经可以工作,但它不适用于具有最新 CommunityToolkit.Maui nuget 的 .NET8。 但是如果您想更改叠加颜色,这里有一个解决方法。 <toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui" ... Color="Black" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" > //make the size to be the full screen size <ContentView WidthRequest="1920" HeightRequest="1080"> <VerticalStackLayout WidthRequest="300" HeightRequest="300" BackgroundColor="Green"> <Image Source="dotnet_bot.png"/> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> </VerticalStackLayout> </ContentView> </toolkit:Popup>


ZSH/Shell变量赋值/使用

我使用 ZSH 作为我的终端 shell,虽然我已经编写了几个函数来自动执行特定任务,但我从未真正尝试过任何需要我目前所追求的功能的东西。 ...


为什么我们不能使用 ${$#} 来获取传递给 shell 脚本的最后一个参数?

我正在阅读 Richard Blum 和 Christine Bresnahan 的《Linux 命令行和 Shell 脚本圣经》。在处理不同特殊变量(如 $# 和 $@)的部分中,他们指出...


无法构建或发布应用程序 maui,有很多错误

我的应用程序在启动时在 IOS 和 Android 上运行良好,但是当我尝试在 Android 上发布应用程序时,我收到所有这些错误: android 应用程序 .net maui 1>C:\Program Files\Microsoft Visual Studio�2\


如何从 shell 脚本获取变量并通过管道传输脚本的输出?

我有一个脚本test.sh: #!/bin/bash 导出 VAR1=abc123 回显$VAR1 我希望在运行此脚本的 shell 中设置 test.sh 中设置的变量,因此我使用源: $ 源 test.sh ...


Python 的语音转文本 API v2 问题(权限被拒绝)

只能在 Google Shell 中使用路径设置命令“exports...”。不要在代码中和我的主平台上使用“PATH”的 shell 工作 Python Local 我面临着一个令人困惑的交通问题...


shell脚本字符转义失败

我的JVM参数配置如下: 设置“JSSE_OPTS=-Djdk.tls.ephemeralDHKeySize=2048” 设置“JAVA_OPTS =%JAVA_OPTS%%JSSE_OPTS%” 设置“PATH_OPTS=-Drelaxed-path-chars=^...


如何在.Net MAUI 中访问麦克风输入?

我正在开发 .net maui 应用程序,该应用程序可以测量音量并通过蓝牙将其发送到记录数据并制作图表的电脑,作为一个业余爱好项目。我的问题是访问麦克风输入。好像有...


MAUI 应用程序在目标升级到 .NET8 后运行模拟器之前抛出错误

我有一个相当简单的.NET MAUI 应用程序,我正在 Win10 上的 Visual Studio 中开发它,然后通过在模拟器中运行它来测试它。它工作得很好,直到我将目标框架从 .NET7 升级到...


如何在 MAUI 中重置所有 DI 服务或用户注销时的 DI 范围?

在我的 MAUI Blazor 应用程序中,用户可以在运行时注销。当他们这样做时,我基本上想重置所有注入的服务,因此当另一个用户登录时,他们会获得“新鲜”状态,避免可能的情况


如何使任何 shell 命令的输出(stdout、stderr)不缓冲?

有没有一种方法可以在没有输出缓冲的情况下运行 shell 命令? 例如,十六进制转储文件 | ./my_script 只会以缓冲块的形式将输入从 hexdump 传递到 my_script,而不是逐行传递。 什么是


在 .NET MAUI ContentView 中充当可绑定属性

ContentView 中的 Bindable 属性可以是 Func 类型吗?也就是说,像这样: 公共部分类 MyControl :ContentView { 公共静态只读 BindableProperty


MAUI:如何在代码中绑定事件属性(sender、EventArgs);绑定到 ViewModel 或代码隐藏

我已使用 XAML 标记成功将 DrogGestureRecognizer 的 Drop 事件绑定到 CodeBehind,如下所示: ...


Shell 脚本:我如何通过 virtualbox 的 cli 列出虚拟机并删除除“SaveThisOne”之外的所有内容?

Shell 脚本:我如何通过 virtualbox 的 cli 列出虚拟机并删除除“SaveThisOne”之外的所有内容? 注意:以下行将删除所有 virtualbox 虚拟机: VBox管理列表正在运行的虚拟机...


Shell 脚本/VirtualBox:我如何设置将通过 vboxmanage cli 保存以防止删除的虚拟机名称列表? [重复]

Shell 脚本/VirtualBox:我如何设置将通过 vboxmanage cli 保存以防止删除的虚拟机名称列表? 由 @BeatOne 编码的第一个解决方案 警告!该 ShellScript 排除了除一个之外的所有虚拟机,


Xamarin Forms 或 .NET Maui 中 RevenueCat 应用内功能的示例代码?

我在这里发布一些示例代码,因为在使用 RevenueCat 开发 Xamarin Forms 应用程序时找不到任何示例代码。


通过底部表单中的参数过滤.NET MAUI MVVM中collectionView的数据

我正在过滤一个从 ObservableCollection 获取数据的 collectionView。逻辑位于 ViewModel 类中。我从 HTTP 请求获取 ObservableCollection 的数据,之后...


将 Xamarin UWP 应用程序升级到毛伊岛后,新更新拒绝安装

这几乎正是我所发生的事情:https://learn.microsoft.com/en-us/answers/questions/1000760/migrate-uwp-app-to-maui-windows-error-after-更新?评论=问题#最新问题-


NET8 MAUI ListView 选择项目为橙色

我过去问过这个问题,得到的答案是这是一个错误,它将在 NET8 中修复。 使用新版本的框架,问题仍然存在。当我跑步时...


如何使用 Docker 在 Ubuntu 上安装 nvm?

到目前为止我有这个: 来自 --platform=linux/amd64 amd64/ubuntu:noble 环境术语 Linux ENV DEBIAN_FRONTEND 非交互式 SHELL [“/bin/bash”,“-c”] 环境外壳 /bin/bash 运行 apt upd...


maui android 应用程序在管道中构建失败,并出现错误“找不到 Android SDK 目录”

如果没有任何代码更改,Android 的管道构建将失败并出现以下错误。 /opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/33.0.95/tools/Xamarin.Android.Tooling.targets(70...


Maui Blazor 按钮点击导航

我有一个带有按钮的页面,该按钮调用异步 webapi,然后导航到另一个页面。然而,尽管代码运行没有错误,但它不会转到新页面。相反,当前...


在Maui注册兼容性PageRenderer导致堆栈溢出异常

我正在尝试重用 Xamarin.Forms 中的现有 PageRenderer 项目,以其迁移的应用程序形式。 当页面开始加载时,出现堆栈溢出异常: Java.Interop.NativeMet 中的 0x39...


.NET MAUI TabBar 登录/注销问题

我遇到一个问题,当用户导航到“设置”选项卡并单击注销选项时,该选项会将用户导航回登录屏幕,但当用户重新登录选项卡栏时,


如何设置 Visual Studio 2022 .Net 7.0 以创建通知侦听器

如何设置 Visual Studio 2022 .Net 7.0 以创建通知侦听器 我正在使用这个文档 https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/notific...


UnicodeDecodeError:“utf-8”无法解码位置 4024984 中的字节 0x90:无效的起始字节

我正在完全跟踪模式下运行子进程并使用 logger.info() 显示它 > std = subprocess.run(subprocess_cmd, shell=True, > universal_newlines=True, stdout=subprocess.PIPE, > 是...


棱镜:ViewModelLocator.AutowireViewModel 不适用于内容视图

我正在将使用 Prism 的 Xamarin.Forms 应用程序迁移到 .NET Maui。该应用程序有一个 TabbedPage 导航。此迁移有效。 但是 ContentPages 包含几个 ContentView,如下所示: 我正在将使用 Prism 的 Xamarin.Forms 应用程序迁移到 .NET Maui。该应用程序有一个 TabbedPage 导航。此迁移有效。 但是 ContentPages 包含几个 ContentView,如下所示: <?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" xmlns:views="clr-namespace:MauiDemo.Views" x:Class="MauiDemo.Views.HomePage" Title="HomePage"> <VerticalStackLayout> <views:FirstContentView HeightRequest="200"/> <views:SecondContentView HeightRequest="200"/> </VerticalStackLayout> </ContentPage> 在 Xamarin 中,我能够将 prism:ViewModelLocator.Autowire="true" 属性添加到 contentview 中,并且 prism 找到了关联的视图模型。在 .NET maui 中,prism:ViewModelLocator.AutowireViewModel="Automatic" 属性没有任何作用。 例如,ContentView 的名称是 “FirstContentView”。关联的viewModel的名称是“FirstContentViewViewModel” 根据https://prismlibrary.com/docs/maui/migration.html中的描述,它应该可以工作,但事实并非如此。 配置这样的自动接线有什么技巧吗? 我使用 prism 存储库的当前克隆 https://github.com/PrismLibrary/Prism 以及带有最新 MAUI 组件的当前 .NET8 SDK 我使用区域而不是通过自动装配。具有不同 ContentView 的页面应该如下所示 <?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" xmlns:views="clr-namespace:MauiDemo.Views" xmlns:prism="http://prismlibrary.com" x:Class="MauiDemo.Views.HomePage" Title="HomePage"> <VerticalStackLayout> <ContentView prism:RegionManager.RegionName="FirstContent"/> <ContentView prism:RegionManager.RegionName="SecondContent"/> </VerticalStackLayout> </ContentPage> 所需的视图及其视图模型应在 MauiProgram 中注册为 RegisterForRegionNavigation container.RegisterForRegionNavigation<FirstContentView, FirstContentViewViewModel>(); container.RegisterForRegionNavigation<SecondContentView, SecondContentViewModel>(); .UsePrism(prism => { prism.RegisterTypes(container => { container.RegisterForNavigation<MainPage,MainPageViewModel>(); container.RegisterForNavigation<HomePage>(); container.RegisterForRegionNavigation<FirstContentView, FirstContentViewViewModel>(); container.RegisterForRegionNavigation<SecondContentView, SecondContentViewModel>(); }) .CreateWindow(navigationService => navigationService.CreateBuilder() .AddSegment<MainPage>() .NavigateAsync(HandleNavigationError)); }) 包含多个ContentView的页面的ViewModel应该为所需的ContentView调用RegionManager.RequestNavigate方法。 public class HomePageViewModel : ViewModelBase, IInitialize { private readonly IRegionManager _regionManager; public HomePageViewModel(IRegionManager regionManager) { _regionManager = regionManager; } public void Initialize(INavigationParameters parameters) { _regionManager.RequestNavigate("FirstContent", nameof(FirstContentView)); _regionManager.RequestNavigate("SecondContent", nameof(SecondContentView)); } } 仅此而已。它的工作原理如https://xamgirl.com/prism-regions-in-xamarin-forms/所述


如何在运行时向IntentFilter添加值

我有一个使用 MSAL 登录的 maui 应用程序,我可以在 android 和 ios 上登录。但我想在运行时将值分配给 DataScheme。我们正在管道中绑定这些值并采取...


使用样式(MAUI)时,文本属性值在运行时不会更改

我使用了标签的样式,并将其文本属性绑定到 ViewModel 中的属性。最初,我使用 ViewModel 中的属性设置标签的文本值。后来我改了...


如何使用 UI .NET MAUI 等弹出控件获得响应式布局

我有这样的 UI 设计,其中左侧有一个弹出/停靠布局用于设置列表,然后在右侧显示所选设置的内容。 在桌面上,我希望 UI ...


C语言linux shell

在提供的代码片段中,我正在寻求有关如何增强其功能的指导。具体来说,我想实现一个功能,当用户输入内置命令以外的命令时(s...


© www.soinside.com 2019 - 2024. All rights reserved.