mvvm-light

mvvmlight messenger strange behaviour

耗尽温柔 提交于 2019-12-06 15:37:20
I have a strange behavior in my project. I use MvvmLight messenger to notify different parts of my UI to update. public EntryViewModel(MenuViewModel menuVM, Entry item) { this._menuVM = menuVM; OpenDetailsCommand = new RelayCommand(OpenDetailsInMainWindow); BackCommand = new RelayCommand(Back); this._entry = item; Refresh(); Messenger.Default.Register<CardUpdateMessage>(this, this._entry.Id, msg => Refresh(); ); } and send with Messenger.Default.Send(new CardUpdateMessage(id), id); when I see Messenger content after registration it contains about 400 registered actions of CardUpdateMessage,

WPF MVVM Light - Show notification before work is done

有些话、适合烂在心里 提交于 2019-12-06 14:03:31
问题 In my MVVM Light application i want to show a notification before i do some some synchronous work that takes two or three seconds. I don't want the user to do anything while the work is being done so there is no need for async, Task and IProgress or backgroundworkers etc. In a ViewModel i have this code. (Note that this is not located in the code-behind of the XAML-file but in a databound ViewModel) void MyCommand(Project project) { NavigationService.AddNotification("Doin' it"); GetTheJobDone

Can the MVVM-Light ViewModelLocator be used in nested ViewModels?

别来无恙 提交于 2019-12-06 13:20:11
问题 The Visual Studio 2008 Designer doesn't seem to like UserControls that reference the MVVM-Light ViewModelLocator. I get an error message like: Could not create an instance of type 'MyUserControl'. For example, the following XAML will cause this behavior if MyUserControl uses the ViewModelLocator to establish its DataContext. <Page x:Class="MyProject.Views.MainView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns

MVVM - Reuse Views with multiple ViewModels

為{幸葍}努か 提交于 2019-12-06 12:55:51
问题 I believe one of the main benefits of MVVM is decoupling, the binding and lack of references makes things a lot more reusable. All MVVM examples I find have some kind of View with a ViewModel with the same naming like ExampleView has a ExampleViewModel . And always a one to one relationship, one View, one ViewModel. But in my current project I have a form to be filled so data can be added to the data base, also the user has the option to edit the data on the data base, so this form View can

MVVM, Confused about ViewModelLocator and DataTemplate, leading to ViewFirst vs ViewModel first

给你一囗甜甜゛ 提交于 2019-12-06 12:34:25
问题 I use MVVMLight and it comes with a ViewModelLocator. My initial project posed the following problem. I have a MainView that is rendered upon stating up the app. Depending on buttons clicked it renders either View1 or View2 (each are user controls) via ContentControl inside my MainView. I locate the correct view model in my MainViewModel. But I found that I also need a DataTemplate so that the usercontrols within View1 and View2 will be correctly rendered in MainView, else it would only show

How to do Regions in WPF without Prism?

别说谁变了你拦得住时间么 提交于 2019-12-06 11:24:34
问题 Specifically in MVVM Light toolkit? I've not dove into the Prism code yet to see what it does in regard to regions in a WPF UI. Seems like with the messaging and the ViewModelLocator in MVVM Light you could do a similar thing....Can you? Can anyone give some examples on how you could do this? Essentially I'd like to click on a button and load two different view models into the UI. Perhaps a better way to explain is Outlook-like Navigation Pane functionality. 回答1: This can be done fairly

MVVM Light Messenger Not Functioning As Expected

[亡魂溺海] 提交于 2019-12-06 11:04:54
问题 A while back I asked a question found here: Use MVVM Light's Messenger to Pass Values Between View Model I went to test the answer today and it doesn't appear to be working. My implementation looks as follows: MessengerInstance.Send(SelectedDocument, Model.StaticEnums.Tokens.SettingstoMain); And: MessengerInstance.Register<XDocument>(this, Model.StaticEnums.Tokens.SettingstoMain, settings => CopySettings(settings)); My problem is, this implementation doesn't work. Instead, the arguments for

SimpleIoC - Type not found in cache: Windows.UI.Xaml.Controls.Frame

扶醉桌前 提交于 2019-12-06 09:39:20
I am running into the below error the first time my ViewModel is being instantiated by the SimpleIoC. I believe I have setup the container as it should be, but for some reason, I am still getting the below error. Any ideas or assistance would be very much appreciated. Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code HResult=-2146233088 Message=Type not found in cache: Windows.UI.Xaml.Controls.Frame. Source=GalaSoft.MvvmLight.Extras StackTrace: at GalaSoft.MvvmLight.Ioc.SimpleIoc.DoGetService(Type serviceType, String key) in c:\Users\Public\Downloads\CodePlex

MVVM Light Commands within an ItemsControl

谁说胖子不能爱 提交于 2019-12-06 09:10:39
问题 I'm just trying my hand at WP7 dev using the MVVM Light framework. I'm trying to fire a button command inside an ItemsControl, essentialy it's a list of cars and I'd like each element to have an edit button. The Relevant piece of the View: <ItemsControl ItemsSource="{Binding MyCars}" > <ItemsControl.ItemTemplate> <DataTemplate> <Grid x:Name="CarViewGrid"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" MinWidth="100" /> <ColumnDefinition Width="Auto" MinWidth="302"/> </Grid

Dynamically Creating Controls Following MVVM pattern

久未见 提交于 2019-12-06 08:48:32
问题 I'd like to dynamically generate some controls in my silverlight application. To be more clear, here's a simplified definition of my class: public class TestClass { [Display(Name="First Name")] public string FirstName { get; set; } [Display(Name = "Last Name")] public string LastName { get; set; } public List<CustomProperty> CustomProperties { get; set; } } Each "CustomProperty" will finally be a TextBox, CheckBox or ComboBox: public class CustomProperty { public CustomDataType DataType { get