mvvm 相关问题

Model-View-ViewModel(MVVM)是一种架构设计模式,用于实现用户界面,通过其表示逻辑(其ViewModel)将UI(View)与其数据(Model)分开。

WPF 绑定在 MahApps.Metro 中出现一些错误,但它可以运行

**在我的xaml中:** **在我的xaml中:* * <! -- Items --> <Controls: HamburgerMenu. ItemsSource> <Controls: HamburgerMenuItemCollection> <Controls: HamburgerMenuItem Command="{Binding LinkViewModel. isMVIRCommand}" Label="WVIR"></Controls: HamburgerMenuItem> <Controls: HamburgerMenuItem Command="{Binding LinkViewModel. isTemperatureCommand}" Label="temperature"></Controls: HamburgerMenuItem> </Controls: HamburgerMenuItemCollection> </Controls: HamburgerMenu. ItemsSource> **In my LinkViewModel: ** public DelegateCommand isMVIRCommand { get; set; } public DelegateCommand isTemperatureCommand { get; set; } isMVIRCommand = new DelegateCommand(isMVIR); isTemperatureCommand = new DelegateCommand(ChangeToTemperature); private void ChangeToTemperature() { isMV = "Collapsed"; isIR = "Collapsed"; isTemperature = "Visible"; } private void isMVIR() { isMV = "Visible"; isIR = "Collapsed"; isTemperature = "Collapsed"; } **follow it's wrong: ** LinkViewModel. isMVIRCommand HamburgerMenuItem. Command ICommand FrameworkElement or FrameworkContentElement can't find the target element management. LinkViewModel. IsTemperatureCommand HamburgerMenuItem.Com and ICommand FrameworkElement or can't find the target element management FrameworkContentElement. 我确信它已经在 LinkViewModel 中 Binding 了,但是当我运行我的项目时,它可以按照我的预期运行,但是我的 wpf 设计器搞错了我。希望有人能帮我找出问题所在 我知道我可以运行该项目的原因,但我的wpf设计师对我有误解。请阅读我的代码。 <Controls:HamburgerMenuItem Command="{Binding DataContext.LinkViewModel.isMVIRCommand, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}" Label="WVIR"/> <Controls:HamburgerMenuItem Command="{Binding DataContext.LinkViewModel.isTemperatureCommand, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}" Label="temperature"/> 我添加了RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}。他们告诉wpf设计器在可以找到MetroWindow时搜索设计器树。在我的情况下,我的MetroWindow DataContext已设置为MainWindowViewModel ,而我的LinkViewModel是MainWindowModel中的一个元素,所以可以在WPF设计器中找到它

回答 1 投票 0

按钮命令未触发 .Net MAUI 中的方法

我是 .Net MAUI 和 MVVM 结构的新手。我有 MainPage.xaml 和 DeletePage.xaml,并且两个页面中都有 1 个按钮,可以通过命令在 MainViewModel.cs 中触发 DeleteColor 方法。我可以解雇删除公司...

回答 1 投票 0

Maui - TabbedPage 将选项卡绑定到 ViewModel 导致 NavigationFailed 错误

我遇到了这个问题,希望有人可以帮助解决它。 示例项目下载 **文件:HomePage.xaml ** 如果我在没有 Viewmodel Binding 的情况下使用此 xaml,它可以正常工作: 我遇到了这个问题,希望有人可以帮助解决它。 示例项目下载 **文件:HomePage.xaml ** 如果我在没有 Viewmodel Binding 的情况下使用此 xaml,它可以正常工作: <?xml version="1.0" encoding="utf-8" ?> <TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:page="clr-namespace:TabbedPageTest.Mvvm.Views" xmlns:viewmodels="clr-namespace:TabbedPageTest.Mvvm.ViewModels" x:Class="TabbedPageTest.Mvvm.Views.HomePage" Title="HomePage" x:Name="mainTabPage" Shell.NavBarIsVisible="False"> <page:HomeContentPage Title="Home" /> <page:SettingsContentPage Title="Settings" /> </TabbedPage> 但是如果我像这样改变它: <?xml version="1.0" encoding="utf-8" ?> <TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:page="clr-namespace:TabbedPageTest.Mvvm.Views" xmlns:viewmodels="clr-namespace:TabbedPageTest.Mvvm.ViewModels" x:Class="TabbedPageTest.Mvvm.Views.HomePage" Title="HomePage" x:Name="mainTabPage" Shell.NavBarIsVisible="False" ItemsSource="{Binding TabCollection}" SelectedItem="{Binding SelectedTab}"> <TabbedPage.BindingContext> <viewmodels:HomePageViewModel/> </TabbedPage.BindingContext> </TabbedPage> HomePageViewModel: public partial class HomePageViewModel : BaseViewModel { public HomePageViewModel() { SetMainTabsTest(); } [ObservableProperty] public ObservableCollection<Page> _tabCollection = []; [ObservableProperty] public Page _selectedTab = null; private void SetMainTabsTest() { TabCollection.Clear(); TabCollection.Add( new HomeContentPage { Title = "Home" }); TabCollection.Add( new SettingsContentPage { Title = "Settings" }); SelectedTab = TabCollection[0]; } } 首页内容页面: <?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="TabbedPageTest.Mvvm.Views.HomeContentPage" Title="HomeContentPage"> <VerticalStackLayout> <Label Text="Dummy text for Home Page"/> </VerticalStackLayout> </ContentPage> 设置内容页面: <?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="TabbedPageTest.Mvvm.Views.SettingsContentPage" Title="SettingsContentPage"> <VerticalStackLayout> <Label Text="Dummy text for Settings Page"/> </VerticalStackLayout> </ContentPage> 我收到错误消息:Microsoft.UI.Xaml.Controls.Frame.NavigationFailed 未处理。 调试,异常 - 内部异常并询问 Google 但没有结果 TabbedPage 与 .NET MAUI Shell 应用程序不兼容,如果您尝试在 Shell 应用程序中使用 TabbedPage,将会抛出异常。我可以看到你的应用程序是。 另一个问题可能是您的视图模型是瞬态的,这可能会添加页面的新实例,这在某些情况下可能并不理想。

回答 1 投票 0

如何为 2 个嵌套列表框 WPF C# 添加双击事件

<Window x:Class="SecutiryQuizApp.Views.Windows.CreateOrEditInspection" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SecutiryQuizApp.Views.Windows" xmlns:contols="clr-namespace:SecutiryQuizApp.UserControls" xmlns:converter="clr-namespace:SecutiryQuizApp.Converters" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" mc:Ignorable="d" Title="Обход" Height="600" Width="600" Icon="/Resources/inspections.ico"> <Window.Resources> <converter:TypeAnswerConverter x:Key="TypeAnswerConverter"/> <converter:BooleanInverterConverter x:Key="BooleanInverterConverter"/> <converter:Base64ToBitmapImageConverter x:Key="Base64ToBitmapImageConverter"/> </Window.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="50*"/> <RowDefinition Height="519*"/> <RowDefinition Height="15*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="20*"/> <ColumnDefinition Width="564*"/> <ColumnDefinition Width="20*"/> </Grid.ColumnDefinitions> <ScrollViewer Grid.Column="1" Grid.Row="1"> <Grid Margin="5,5,5,5"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <ComboBox Grid.Row="1" ItemsSource="{Binding QuizCollection}" SelectedItem="{Binding SelectedQuiz, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,10,0,0" materialDesign:HintAssist.Hint="Выберите опрос..." FontFamily="Bahnschrift" FontSize="16" Background="White" IsEnabled="{Binding VisibilityDonut, Converter={StaticResource BooleanInverterConverter}}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> <ListBox x:Name="QuestionsList" Grid.Row="3" ItemsSource="{Binding QuestionsCollection}" Margin="0,10,0,10" FontSize="16" HorizontalAlignment="Stretch" IsEnabled="{Binding VisibilityDonut, Converter={StaticResource BooleanInverterConverter}}" > <ListBox.Template> <ControlTemplate TargetType="{x:Type ListBox}"> <ScrollViewer CanContentScroll="False"> <ItemsPresenter /> </ScrollViewer> </ControlTemplate> </ListBox.Template> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Height" Value="auto"/> <Setter Property="Background" Value="White"/> <Setter Property="Margin" Value="0 -2 0 0"/> <Setter Property="VerticalContentAlignment" Value="{Binding VerticalAlignment, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalAlignment, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="3" CornerRadius="7"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="10"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="10"/> </Grid.ColumnDefinitions> <Grid Grid.Column="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <TextBlock Text="{Binding Description}" Grid.Row="0" Grid.Column="0" TextTrimming="CharacterEllipsis" Name="name" FontWeight="Medium" Foreground="Black" VerticalAlignment="Top" Margin="10 5 0 0" FontSize="15" FontFamily="Bahnschrift"/> <TextBlock Opacity="0" Grid.Column="1" Grid.Row="0" Width="Auto" Text="{Binding idTypeAnswer, Converter={StaticResource TypeAnswerConverter}}" MaxHeight="30" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Name="description" FontWeight="SemiBold" Foreground="Black" VerticalAlignment="Top" Margin="10 7 0 0" FontSize="12" FontFamily="Bahnschrift"/> <ListBox Grid.Row="1" x:Name="ImagesList" ItemsSource="{Binding ImagePathsCollection}" MaxHeight="120" FontSize="16" Grid.ColumnSpan="2"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush="Transparent" CornerRadius="15"> <Grid> <Image Source="{Binding Converter={StaticResource Base64ToBitmapImageConverter}}" Width="35" Height="35"/> </Grid> </Border> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <ListBox Grid.Row="2" Margin="5,5,5,5" ItemsSource="{Binding Answers}" x:Name="ListAnswers" Grid.ColumnSpan="2" Background="LightYellow"> <ListBox.Template> <ControlTemplate TargetType="{x:Type ListBox}"> <ScrollViewer CanContentScroll="False"> <ItemsPresenter /> </ScrollViewer> </ControlTemplate> </ListBox.Template> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Height" Value="40"/> <Setter Property="Background" Value="LightYellow"/> <Setter Property="Margin" Value="0 -2 0 0"/> <Setter Property="VerticalContentAlignment" Value="{Binding VerticalAlignment, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalAlignment, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="3" CornerRadius="7"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="10"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="40"/> </Grid.ColumnDefinitions> <Grid Grid.Column="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions> <TextBlock Text="Ответ: " FontSize="20" FontFamily="Bahnschrift" Grid.Column="0" VerticalAlignment="Center"/> <TextBlock Text="{Binding Answer}" FontSize="20" FontFamily="Bahnschrift" Grid.Column="1" VerticalAlignment="Center"/> </Grid> <Button Grid.Column="2" Background="Red" Width="20" Height="20" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,5,0" Command="{Binding DataContext.RemoveMarkCommand, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}" CommandParameter="{Binding}"> <Button.Template> <ControlTemplate TargetType="Button"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="20"> <iconPacks:PackIconMaterial Width="10" Height="10" VerticalAlignment="Center" HorizontalAlignment="Center"> <iconPacks:PackIconMaterial.Style> <Style TargetType="iconPacks:PackIconMaterial"> <Setter Property="Kind" Value="close"/> </Style> </iconPacks:PackIconMaterial.Style> </iconPacks:PackIconMaterial> </Border> </ControlTemplate> </Button.Template> </Button> </Grid> </Border> <ControlTemplate.Triggers> <MultiTrigger> <Setter Property="Background" Value="LightYellow"/> </MultiTrigger> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="LightYellow"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="LightGray"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ListBox.ItemContainerStyle> <i:Interaction.Triggers> <i:EventTrigger EventName="PreviewMouseDoubleClick"> <i:InvokeCommandAction Command="{Binding DataContext.OpenAnswerEditCommand, ElementName=ListAnswers}" CommandParameter="{Binding}"/> </i:EventTrigger> </i:Interaction.Triggers> </ListBox> </Grid> </Grid> </Border> <ControlTemplate.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsMouseOver" Value="True"/> </MultiTrigger.Conditions> <MultiTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="description" Storyboard.TargetProperty="Opacity" BeginTime="0:0:0" From="0" To="1" Duration="0:0:0.2" /> </Storyboard> </BeginStoryboard> </MultiTrigger.EnterActions> <MultiTrigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="description" Storyboard.TargetProperty="Opacity" BeginTime="0:0:0" From="1" To="0" Duration="0:0:0.2" /> </Storyboard> </BeginStoryboard> </MultiTrigger.ExitActions> <Setter Property="Background" Value="#edeaf4"/> </MultiTrigger> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="#eff3fb"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#FFECECEC"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ListBox.ItemContainerStyle> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDoubleClick"> <i:InvokeCommandAction Command="{Binding EditOrAddQuestionCommand}" CommandParameter="{Binding SelectedItem, ElementName=QuestionsList}"/> </i:EventTrigger> </i:Interaction.Triggers> </ListBox> <Button Grid.Row="4" Content="Сохранить изменения" HorizontalAlignment="Stretch" VerticalAlignment="Top" Command="{Binding SaveQuizCommand}" Margin="0,10,0,10" Background="#FF2196F3" BorderBrush="#FF2196F3" Foreground="White" FontFamily="Bahnschrift" FontSize="16" IsEnabled="{Binding VisibilityDonut, Converter={StaticResource BooleanInverterConverter}}"/> </Grid> </ScrollViewer> <Grid Grid.Column="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="119*"/> <ColumnDefinition Width="37*"/> <ColumnDefinition Width="53*"/> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> <TextBlock Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" FontFamily="Bahnschrift" FontSize="22" TextAlignment="Center" Margin="0,0,0,5"><Run Language="ru-ru" Text="Обход"/></TextBlock> <Button Grid.Column="3" Content="Удалить обход" VerticalAlignment="Bottom" Command="{Binding RemoveQuizCommand}" Background="#FFFF4C30" BorderBrush="#FF2196F3" Foreground="White" FontFamily="Bahnschrift" FontSize="16" IsEnabled="{Binding VisibilityDonut, Converter={StaticResource BooleanInverterConverter}}" Grid.ColumnSpan="2" Margin="0,0,0,5"/> </Grid> <contols:DonutSpinner Grid.Row="1" Visibility="{Binding VisibilityDonut, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" Grid.Column="1" VerticalAlignment="Stretch" MaxWidth="80"/> </Grid> </Window> using SecutiryQuizApp.Models; using SecutiryQuizApp.ViewModels; using System.Windows; namespace SecutiryQuizApp.Views.Windows { public partial class CreateOrEditInspection : Window { public CreateOrEditInspection(InspectionAnswer inspection) { InitializeComponent(); this.DataContext = new OpenOrEditInspectionVM(inspection); } } } public RelayCommand OpenAnswerEditCommand { get { return new RelayCommand(parameter => { if (parameter is InspectionAnswer question) { OpenEditAnswer(question); } }); } } private InspectionAnswer inspection { get; set; } public OpenOrEditInspectionVM(InspectionAnswer _inspection) { inspection = _inspection; Runner(); } 我遇到了 PreviewMouseDoubleClick OpenAnswerEditCommand 事件在我的 WPF 应用程序中无法按预期工作的问题。我有一个名为 ListAnswers 的列表框,我想在双击 ListAnswers 中的 ListBoxItem 时触发视图模型中的 OpenAnswerEditCommand 命令。然而,尽管在XAML中设置了事件触发器,但该命令似乎没有被执行。 绑定到第二个 DataContext 父级的 ListBox: <i:InvokeCommandAction Command="{Binding DataContext.OpenAnswerEditCommand, RelativeSource={RelativeSource AncestorType=ListBox, AncestorLevel=2}}" CommandParameter="{Binding}"/> 或者父窗口: <i:InvokeCommandAction Command="{Binding DataContext.OpenAnswerEditCommand, RelativeSource={RelativeSource AncestorType=Window}}" CommandParameter="{Binding}"/> 此处不能使用 ElementName,因为嵌套的 ListBox 与外部的名称范围不同。

回答 1 投票 0

使用MVVM将ListView绑定到ObservableCollection

我正在开发一个毛伊岛应用程序。我使用 MVVM 结构和 MVVM 社区工具包来更轻松地生活。现在,我在显示绑定到 My

回答 1 投票 0

flutter中MVC和MVVM的区别

我不明白mvc和mvvm之间的区别! 有人可以帮我解释一下吗? 在MVC中: 模型 类用户模型{ 迟到的 int id; 迟到的字符串名称; 迟到的字符串电子邮件; 用户模型({要求...

回答 2 投票 0

如何将WPF ComboBox宽度设置为XAML中最大项目的大小?

我有一个组合框: 我有一个组合框: <ComboBox Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" ItemsSource="{Binding Options}" SelectedItem="{Binding SelectedOption}" DisplayMemberPath="DisplayName"/> Options 中的第一项将始终包含一个选项,其中 option.DisplayName = string.Empty 这会导致组合框非常薄,因为不需要空间来显示 string.Empty。 在 XAML 中,有没有办法自动将 ComboBox 的宽度设置为 ItemsSource 中最大字符串的大小?我不想测量最长项目的宽度并将其设置在 .xaml.cs 如果重要的话,组合框所在的网格看起来像: <Grid Margin="5" Height="500"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> 如果您希望将 ComboBox 在布局中居中,但仍希望其自动调整大小,则可以使用 Grid 作为布局容器。这样Grid就会照顾好你的ComboBox。 由于您已经在使用 Grid 来布局元素,因此您所要做的就是定义列。 只需创建至少三列(您可以使用 Grid.ColumnSpan 将列合并为居中元素的三列行)并将 ComboBox 放置在中心列中。在其他元素上设置 Grid.ColumnSpan,以允许它们跨越整个 Grid。然后将 HorizontalAlignment 的 ComboBox 设置回 HorizontalAlignment.Stretch(这是默认值): <Grid Margin="5" Height="500"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> <!-- Center column --> <ColumnDefinition /> </Grid.ColumnDefinitions> <!-- The centered ComboBox element --> <ComboBox Grid.Row="1" Grid.Column="1" /> <!-- A TextBox element that stretches across the full Grid --> <TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" /> </Grid>

回答 1 投票 0

SwiftUI ViewModel 未被 deinit 并导致内存泄漏

我正在 Xcode 上开发一个 Mac OS 应用程序,该应用程序从 API 中提取足球排名并将其显示在视图中。我注意到我的内存不断增加,在使用 Xcode Memory Graph 之后,我相信......

回答 1 投票 0

是否可以使用社区工具包将可观察属性配置为只读?

我正在使用 CommunityToolkit 在视图模型中配置绑定属性,但在某些情况下,我只想将该属性设置为只读。所以我正在尝试这个: [可观察属性] 噗...

回答 1 投票 0

WPF MVVM 导航视图。问题继续创建视图实例

我想要实现的是,当我点击按钮时,视图切换。 但是,每当切换 Viewmodel 时,View Instance 都会继续创建。 我只想创建和重用视图

回答 1 投票 0

使用 MVVM 和 .NET MAUI 加载视图时如何将焦点设置到特定的条目控件

我在 .NET MAUI MVVM 项目中有一个带有输入控件和两个按钮的视图。当视图加载时,输入控件未获得焦点。如何在不添加

回答 3 投票 0

如何从媒体播放器检索当前持续时间以显示在歌曲进度条上?

我已经尝试了所有可能的步骤,但只给出了一次价值,我希望它应该每秒更新一次。这是我的代码,我哪里做错了? 我想实现音乐进度滑块,任何......

回答 1 投票 0

WPF 绑定不更新视图

我有一个文本块: ... 地位 ... 代码...

回答 9 投票 0

将一个实体添加到多个弹出窗口 - WPF

我想知道是否可以一次将一个实体添加到多个窗口。一个例子是我有 3 个弹出窗口用于不同类型的培训。我扫描自己(条形码)和

回答 1 投票 0

Avalonia ReactiveUI 中如何识别触摸屏手势

我正在尝试使用 MVVM 模式来处理 Avalonia。我正在尝试创建一个识别触摸屏手势的应用程序。 到目前为止,我已经创建了带有简单图形的应用程序,但我...

回答 1 投票 0

System.InvalidOperationException 发生在我的 WPF 应用程序中

我正在按照 MVVM 模式编写 WPF 应用程序,我的视图中有 DataGrid。我还有 4 个文本框、1 个组合框和一个用于将新实体添加到 DataGrid 的按钮。我正在使用实体框架...

回答 1 投票 0

如何使 ObservableObject 派生类的更改自动反映到接口中?

我在 WPF 程序中使用 CommunityToolkit 中的 ObservableObject。它看起来像这样: 我认为它就像一个 ViewModel: 公共类 MyParameters:ObservableObject { // 他还有许多其他值...

回答 2 投票 0

Kotlin,无法创建 Viewmodel 类的实例

我是 MVVM 架构的新手,我尝试过不同的选项,但仍然得到相同的异常“无法创建实例 ViewModel”。 我正在使用 Android Studio Iguana 下面我...

回答 1 投票 0

使用 MVVM,如何从 DataTable 动态生成 WPF DataGrid 列并显示按钮列?

我试图从数据表动态生成数据网格,同时显示两个用于“编辑”和“删除”功能的按钮列。我可以在 XA 中手动创建按钮列...

回答 1 投票 0

MvvmLight 工具包安装程序 4.0.23.1.msi,未安装 VS2010 模板

我正在运行 GalaSoft MvvmLight Toolkit MSI 安装程序 (GalaSoft.MvvmLight.4.0.23.1.msi),但我没有安装任何模板或片段。

回答 2 投票 0

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