mvvm-light

A super-simple MVVM-Light WP7 sample?

 ̄綄美尐妖づ 提交于 2019-12-28 05:35:27
问题 I am looking for a sample that demonstrates in the lightest way possible the following: A Model that invokes a SOAP based web service; regularly polling to get the latest value (assume the SOAP service returns a boolean). The model should also support invoking a SOAP method that changes the boolean on the server. A ViewModel that enables the underlying boolean to be bound to controls in the View (e.g. to a checkbox). A View with the above checkbox control bound to the underlying boolean.

Show dialog with MVVM Light toolkit

笑着哭i 提交于 2019-12-28 05:10:06
问题 I have a ViewModel that needs to show a modal window (using ShowDialog() ) on a button click. The ViewModel catches the click command, but I don't want to do window.ShowDialog() within my ViewModel. I know there is a DialogMessage in MVVM Light, but that is used to show message boxes, not WPF modal windows. Any ideas on how to do this? 回答1: You should use Messenger class. On the View register a message to show window and then when you need to show it call Send method of Messenger class. You

How to have multiple pairs “View-ViewModel”?

岁酱吖の 提交于 2019-12-28 04:13:05
问题 I am building an application that is based on MVVM-Light. I am in the need of creating multiple instances of the same View, and each one should bind to its own ViewModel. The default ViewModelLocator implements ViewModels as singletons, therefore different instances of the same View will bind to the same ViewModel. I could create the ViewModel in the VMLocator as a non-static object (as simple as returning new VM()...), but that would only partially help me. In fact, I still need to keep

MVVM Light RelayCommand Parameters

爷,独闯天下 提交于 2019-12-27 23:35:34
问题 I'm having an issue with passing a parameter to a relaycommand using the GalaSoft MVVM Light framework. I know that mvvm light's implementation of relaycommand doesn't use lambda parameters, so I did some research and found a way that people worked around it by doing something like this: public RelayCommand ProjMenuItem_Edit { get { if (_projmenuItem_Edit == null) { //This should work.... _projmenuItem_Edit = new RelayCommand(ProjEditNode); } return _projmenuItem_Edit; } } private void

RaiseCanExecuteChanged event

女生的网名这么多〃 提交于 2019-12-25 16:04:27
问题 I am at the stage in a project where I need to get control of enabling / disabling some hyperlinks based on various business rules. I noticed all topics on RaiseCanExecuteChanged event refer to MVVM light. Does this mean that I have to use MVVM light or is there a way to access this event using standard MVVM. If so, how? Thanks 回答1: ICommands have an event that command watchers subscribe to. When this event fires, it is the responsibility of the watchers (Button, etc) to call CanExecute in

MVVM Light - using ViewModelLocator - properties hit multiple times

怎甘沉沦 提交于 2019-12-25 11:55:01
问题 I'm making use of the MVVM Light ViewModelLocator. I have a class called GlobalViewModelLocator which is hooked up in the resources in the App.Xaml. This class has a static property called Main which returns an instance of the MainViewModel. Then in the MainView.Xaml, I set the datacontext of the usercontrol to bind to the path of this MainViewModel. This works fine - I put a breakpoint on the MainViewModel constructor and it is being hit once. However, all the properties in the ViewModel

MVVM Light Navigation Service - Change MainWindow Title and Size

℡╲_俬逩灬. 提交于 2019-12-25 09:17:58
问题 I'm creating a new WPF application with (my first WPF app): .Net 4.0 MVVM Light C# MahApps Metro I've already implemented navigation using the Navigation Service in MVVM Light. I'm using a MainWindow and Pages in order to accomplish the same. In my MainWindow.xaml I have a MainFrame that is changing my current View: <Controls:MetroWindow x:Class="App.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns

mvvm calculated fields

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 08:06:09
问题 I am using the MVVM light toolkit for a wpf application which talks to a wcf server. The wcf server returns a Person object (proxy object). This person object has several fields, name, surname, etc etc. My viewmodel calls the webservice, and then gets a return of this model. My view is bound to viewmodel's model, and the fields correctly bound to each ui textbox. all cool in the shade, system functions nicely. two fields on the model are DateOfBirth, and NationalIDNumber (fyi: in south africa

How to have multiple instances of the same ViewModel in MVVM Light?

*爱你&永不变心* 提交于 2019-12-25 05:09:43
问题 I'm using MVVM Light for a WPF application with tabs (a bit like Internet Explorer). Each tabs has to be a couple of unique View and View models. I know know how many instances I will have in my tab control. Due to the design of MVVM Light I can't have multiple instances of a ViewModel at the same moment (static property in the locator). On the codeplex Website i found the following solution : The way I handle this is by making the ViewModel property in the ViewModelLocator (for example the

WPF dependency property MVVM

泪湿孤枕 提交于 2019-12-25 05:09:34
问题 I am in the process of creating a user control, this control will do some work and then populate three dependency properties, which will then used by parent elements of the control through binding. My question is what are the best practices on where to keep the dependency properties using MVVM? Should I use a framework for MVVM? Thanks 回答1: Idiomatic dependency properties have nothing to do with 'view state' as represented by the ViewModel and there is no reason to add them to the ViewModel.