我在使用GalaSoft MVVM Light框架向Light命令传递参数时遇到了问题。我知道mvvm light的relaycommand实现没有使用lambda参数,所以我做了一些研究,找到了一种方法,人们可以这样做来解决这个问题:
public RelayCommand ProjMenuItem_Edit
{
get
{
if (_projmenuItem_Edit == null)
{
//This should work....
_projmenuItem_Edit = new Relay
我正在使用mvvm-light,我注意到了关于RaisePropertyChanged的这种奇怪的行为。
xaml:
<ListBox ItemsSource="{Binding Collection}"/>
<TextBlock Text="{Binding Text}"/>
可观察类:
public class A : ObservableObject
{
private string _b;
public string B
{
get { return this._b; }
s
我用mainView和其他两个视图(用户控件)创建了一个示例。我已经在子视图上放置了一个按钮" close“,我想要关闭该视图。该按钮上有一个命令,当按下close时,我会请求ViewModelLocator将其清除。
但是-视图仍在显示..我哪里做错了?如何使用mvvm-light关闭userControl视图?
private RelayCommand _closeCommand;
public RelayCommand CloseCommand
{
get
{
if (_closeCommand ==
我正在学习MVVM Light,我正在开发的应用程序具有搜索事件名称的功能。下面是我在用户输入ListBox时过滤TextBox的代码。错误是:Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<NGO_Volunteer_Comm_Platform_v1._0.DataModel.Event>' to 'System.Collections.Generic.List<NGO_Volunteer_Comm_Platform_v1._0.DataModel.Even
我正在为WPF应用程序使用MVVM light。我有一个视图模型,其中包含几个使用RelayCommand的命令。由于每个命令的代码非常相似,因此我创建了一个GetCommand方法。但是,如果我在RelayCommand中使用参数,则生成的RelayCommand不起作用。如果我不使用参数,一切都可以正常工作(除了我不能传递一个值)。
谁能解释一下为什么会发生这种情况,还有什么其他的解决方案可以在不复制粘贴的情况下重用代码?
下面是我的代码的一个非常精简的版本,它只显示了重要的部分:
public class MainViewModel {
public RelayCommand co
我正在开发一个基于MVVM模式的UWP应用程序。为了绑定UI操作,我在虚拟机中使用ICommand,我需要为它提供一个指向Windows.Input .Is It的引用,这会破坏虚拟机。 如果我创建了一个实现ICommand接口的类,并将其用于命令绑定,那么它就打破了“编写接口代码”的规则。 //This is what i am doing currently
public ICommand command;
command = new RelayCommand();
// I have tried this to remove the reference of windows.inp
我正在学习WPF和MVVM,目前有一个小问题。
我正在使用MVVM Light,我想在验证后取消/启用一些按钮,但它不使用功能。
ViewModelMain:
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using
在我的C# WPF MVVM应用程序中有以下代码。
public RelayCommand PolishCommand
{
get
{
polishcommand = new RelayCommand(e =>
{
PolishedWeightCalculatorViewModel model = new PolishedWeightCalculatorViewModel(outcomeIndex, OutcomeSelectedItem.RoughCarats);