mvvm-light

Is it possible to send a List<Object> in MVVM Light Message

三世轮回 提交于 2020-01-04 04:09:07
问题 Is it possible to send a List in MVVM Light Message. For example, I have a class named Authors. I want to send Messenger.Default.Send(AuthorList); // AuthorList is of type List<Author> in the constructor of the view model I am writing Messenger.Default.Register<List<Author>>(this, authList => {MessageBox.Show(authList[0].name)}); I have made sure that the constructor is called before I send the message. But it doesn't seem to work. 回答1: Yes . Create your class (I'm using MyTest which has a

Updating UI when a model property changes in an ObservableCollection?

强颜欢笑 提交于 2020-01-04 03:09:41
问题 I have a view that has a group of images I get from a web service I receive them in a list of this class: public class ImageModel { public int Id { get; set; } public string Name { get; set; } public string imageUrl { get; set; } } under each image I show an up-vote button, so I added another bool property to the model above: public bool UpVoted { get; set; } the ListView that shows these images is bound to an ObservableCollection<ImageModel > , I want to change the voting icon through a

MVVM Messaging vs RaisePropertyChanged<T>

ぃ、小莉子 提交于 2020-01-04 02:39:09
问题 What is the difference between MVVM messaging and RaisePropertyChanged. I'm trying to run a function in View model A when a property in view model B changes, which approach is a better one to use - Messaging or RaisePropertyChanged broadcast? Thanks, Nikhil 回答1: Messaging decouples your view models. It's like a Tweet, you send out a message into the air and someone can read it or someone could register to listen for it. PropertyChanged is used by the UI to know that something changed and to

Binding to another viewmodel

扶醉桌前 提交于 2020-01-03 06:02:46
问题 I am trying to bind a visibility property to a function I made in a viewmodel ( MainViewModel ), but I am getting this error: A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll System.Windows.Data Error: BindingExpression path error: 'Main' property not found on 'Locator' 'System.String' (HashCode=-191326816). BindingExpression: Path='Main.TilesHomeViewVisible' DataItem='Locator' (HashCode=-191326816); target element is 'myApp.Views.TilesHomeView'

How to write test case for Dialog services MVVM Light

妖精的绣舞 提交于 2020-01-02 09:57:37
问题 I am new very new to MVVM and i am following MVVM Light toolkit. To implement a message box functionality i searched and got this example The points i didn't understand is Class DialogService is what we should create by inheriting IDialogService ?? If that is the case for example in the class after inheriting the interface we need to write something like below public Task<bool> ShowMessage(string message, string title, string buttonConfirmText, string buttonCancelText, Action<bool>

Mvvm Light and Visual C# Express?

青春壹個敷衍的年華 提交于 2020-01-02 08:06:30
问题 Does MVVM Light work with Visual C# Express? Can't seem to get any of the templates showing up. 回答1: At this point, I do not support Visual C# express for MVVM Light templates. I only support express editions for the Windows Phone and for Windows 8 (Visual Studio 11 for WinRT). I will consider supporting Visual C# express in a further revision of the installer. Unfortunately supporting new versions of Visual Studio is quite a lot of work to update the MSI... 回答2: It's quite easy to take the

Mvvm Light and Visual C# Express?

走远了吗. 提交于 2020-01-02 08:06:21
问题 Does MVVM Light work with Visual C# Express? Can't seem to get any of the templates showing up. 回答1: At this point, I do not support Visual C# express for MVVM Light templates. I only support express editions for the Windows Phone and for Windows 8 (Visual Studio 11 for WinRT). I will consider supporting Visual C# express in a further revision of the installer. Unfortunately supporting new versions of Visual Studio is quite a lot of work to update the MSI... 回答2: It's quite easy to take the

How to clear a TextBox in MVVM?

被刻印的时光 ゝ 提交于 2020-01-01 18:05:48
问题 I have a TextBox in a DataTemplate declared as follows: <TextBox Grid.Row="1" Grid.Column="1" Margin="0,4,0,0"> <i:Interaction.Triggers> <i:EventTrigger EventName="LostFocus"> <cmd:EventToCommand Command="{Binding DataContext.NotesEnteredCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"> <cmd:EventToCommand.CommandParameter> <MultiBinding Converter="{StaticResource SimpleMultiValueConverter}"> <Binding Path="Row.OID" /> <Binding Path="Text" RelativeSource="

How to clear a TextBox in MVVM?

和自甴很熟 提交于 2020-01-01 18:05:01
问题 I have a TextBox in a DataTemplate declared as follows: <TextBox Grid.Row="1" Grid.Column="1" Margin="0,4,0,0"> <i:Interaction.Triggers> <i:EventTrigger EventName="LostFocus"> <cmd:EventToCommand Command="{Binding DataContext.NotesEnteredCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"> <cmd:EventToCommand.CommandParameter> <MultiBinding Converter="{StaticResource SimpleMultiValueConverter}"> <Binding Path="Row.OID" /> <Binding Path="Text" RelativeSource="

MVVM Light : RelayCommand : define it lazy or in constructor?

限于喜欢 提交于 2020-01-01 12:16:35
问题 There are several examples on how to define a RelayCommand in the ViewModel : Option 1 ( lazy ): /// <summary> /// Gets the LogOnCommand. /// </summary> /// <value>The LogOnCommand.</value> public RelayCommand<LogOnUser> LogOnCommand { get { if (this.logOnCommand == null) { this.logOnCommand = new RelayCommand<LogOnUser>( action => { // Action code... }, g => g != null); } return this.logOnCommand; } } Option 2 (in constructor) /// <summary> /// Initializes a new instance of the <see cref=