community-toolkit-mvvm 相关问题


EF Core 脚手架数据和属性已更改

我有一个 WPF 应用程序(MVVM Toolkit),其数据模型是使用数据库中的 EFcore 工具搭建的。一个特定类的最终模型如下所示: 公共部分B类...


TypeScript Redux 在刷新页面时丢失状态

redux/reducer/cartReducer.ts 从“@reduxjs/toolkit”导入{createSlice,PayloadAction}; 从“../../types/reducer-types”导入{ CartReducerInitialState }; 导入 { 购物车项目,


为什么最新的WDK默认不支持Windows 7?

我下载了针对 Windows 7 的驱动程序(在“.vcxproj”中有选项“TargetVersion”==“Windows 7”)。我还安装了 Visual Studio 2022 Community、最新的 SDK 和...


在操作中检测到不可序列化的值(redux-toolkit)

在store中action的payload中,我使用File类型存储下载的文件,然后该文件将在saga中通过验证 const form = new FormData(); if (私钥 &&


在 WPF MVVM 应用程序中使用依赖项注入处理对用户可选择文件的数据访问的正确方法是什么?

考虑以下情况: MVVM 桌面 GUI 应用程序,用户可以在其中创建/编辑“项目”。 想象一个像 Visual Studio 解决方案这样的项目:它是一个文件(当前是......


构建进程异常终止 IntelliJ IDEA

很长一段时间以来,我在尝试在 Intellij IDEA Community Edition 2023.3 中编译任何 Java 程序时遇到各种错误。 编译以下代码时: 导入 javax.swing.*; 导入jav...


D3DCSX 11 连接和运行 FFT 功能时出现问题

根据标题,我在使用 D3DCSX 11 设置和运行基于 DirectX11 GPU 的 FFT 时遇到问题 (系统:Win10 Pro + MS Visual Studio Community 2022(版本:17.8.3)、Windows kit 10(版本:10.0.22621.0)...


使用 /std:c++latest 时,Intellisense 显示标准库中的错误,但项目编译正常

我正在使用 VS2022 Community 构建一个软件,该软件在其 CMakeLists.txt 中标记为使用 C++23 或 /std:c++latest。 该软件构建良好,但“错误列表”平移......


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

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


在 Angular 15 升级中遇到加载器解析 ag-grid/angular.css 文件的问题

我在将 Angular 14 升级到 15 时遇到此构建错误。 我尝试添加 css 加载器,但没有用 ./node_modules/@ag-grid-community/styles/ag-grid.css?ngGlobalStyle:1:0 - 错误:模块解析失败...


为什么我的 Unity VR 项目无法构建和运行? [已关闭]

我想为我的任务 2 统一创建一个游戏。我从包管理器(Open XR 和 XR Interaction Toolkit)下载了一个入门包,一切似乎都很顺利。我有一台 Mac,所以


变量改变时变量值的显示不改变(Jetpack Compose Android Studio)

应用程序使用mvvm和jetpack compose,屏幕(View,compose)使用以下代码显示是否已获得权限: val 上下文 = LocalContext.current 通过 remem 访问 val...


当我尝试将 model.predict() 与 Keras 顺序模型一起使用时,出现意外的 Tensorflow ResourceExhaustedError

我使用的是 Python 3.9,并且安装了 Tensorflow 2.10 和 CUDA Toolkit 11.2 和 cuDNN 8.2,因为这是 Windows 10 上原生支持的最后一个配置。 我正在使用 NVI 进行训练...


单击 Microsoft Visual Studio 顶部菜单选项上的“添加事件处理程序...”不会执行任何操作

我在两个版本的 Microsoft Visual Studio 上遇到了此问题:Community 2017 版本和 Enterprise 2019 版本。当我右键单击菜单项时,我试图添加一个事件......


如何使用CommunityToolkit.Mvvm初始化ViewModel

我们有一个带有 FreshMvvm 的 Xamarin.Forms 应用程序。现在,由于 Xamarin.Forms 从明年开始将不再获得支持,因此我正在使用 .Net Maui 重写该应用程序。对于 MVVM 模式,我正在尝试使用 CommunityToo...


如何在WPF MVVM中显示带有动态列的表格

我有一个对象列表,每个对象都包含用户定义的属性。这些属性的键和值是自由字符串,因此它们在对象之间不一定一致。无论如何,我


MVVM:ViewModel逻辑需要来自数据库的信息,但是如何等待数据?

我是 MVVM 新手,正在尝试弄清楚如何组织我的应用程序。我制作了一个简化的登录应用程序来帮助解决问题。 我将应用程序分为几层:Activity -> ViewModel -> Reposit...


如何进行多个异步网络调用并一次更新插入它们?

我有一个采用 MVVM 架构的应用程序。 DB 是唯一的事实来源。如果数据过时,我想通过从网络获取最新信息来刷新记录。 我必须制作一个单独的网络...


来自 API 的图像在 iOS 上加载,但在 Android 上不加载(Compose 多平台)

我正在制作我的第一个撰写多平台应用程序并遇到一些问题。 通过 Kamel 和 Moko MVVM 从我的 API 获取一些图像。 在 iOS 上可以,但在 Android 上不行。当然网络权限是...


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>


.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>


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