mvvm-light

How to reset all instances in IOC Container

时光毁灭记忆、已成空白 提交于 2019-12-04 09:52:51
I have made an C# WPF Application using the MVVM Light framework . My Application uses the ViewModelLocator class to locate the viewmodels during runtime. The ViewModelLocator makes usage of the SimpleIoc class which also comes with the MVVM Light framework . Here is my scenario: The user logs in an can use my application. On logout, i want to dispose/reset/recreate all viewmodel instances to provide a clean environment to the next user. I tried to implement the Cleanup() method in the ViewModelLocator class but it is not working. Not working means that the (second) user sees the data from the

ICommand CanExecute not triggering after PropertyChanged?

…衆ロ難τιáo~ 提交于 2019-12-04 08:48:32
问题 I got a WPF application that shows a button bound to a command like that: <Button Command="{Binding Path=TestrunStartCommand}" Content="GO!"> The command is defined like that: public ICommand TestrunStartCommand { get { return new RelayCommand(TestrunStartExecute, () => !IsTestrunInProgress); } } public bool IsTestrunInProgress { get{ return _isTestrunInProgress; } set{ _isTestrunInProgress = value; RaisePropertyChanged(IsTestrunInProgressPropertyName); } } The problem is, the button won't be

WPF Binding filtered ObservableCollection ICollectionView to Combobox

你说的曾经没有我的故事 提交于 2019-12-04 08:01:18
I want to filter an ObservableCollection to a subset based on type (type AddPoint) and want it ordered ascending with no duplicates. My base class is ModelBase, w/ sub-classes AddPoint, Time, Repeat, etc... The ObservableCollection MotionSequenceCollection will be filled w/ those types in any order and some will be duplicates. I've tried several different times and shown them below in the ICollectionView Property that I 'pulled' from: Bind subset of collection . OBSERVABLE COLLECTION private ObservableCollection<ModelBase> _motionSequenceCollection = new ObservableCollection<ModelBase>();

Silverlight 4 + MVVM + KeyDown event

你离开我真会死。 提交于 2019-12-04 07:39:41
I'm trying to build a sample game in Silverlight 4 using the MVVM design pattern to broaden my knowledge. I'm using Laurent Bugnion's MvvmLight toolkit as well (found here: http://mvvmlight.codeplex.com/ ). All I want to do right now is move a shape around within a Canvas by pressing specific keys. My solution contains a Player.xaml (just a rectangle; this will be moved around) and MainPage.xaml (the Canvas and an instance of the Player control). To my understanding, Silverlight doesn't support tunneling routed events, only bubbling. My big problem is that Player.xaml never recognizes the

UWP - Perform long view model creation and keep UI responsive

帅比萌擦擦* 提交于 2019-12-04 06:17:57
问题 I've build this example to show my issue. I need to create a hierarchy to be shown in a treeview, treeview to be bound to the view model. In the good old days of VB6 I would have used DoEvents to unlock the UI but here I'm not able to understand how to proceed. On VS19 create a blank UWP project and call TestLoadSync it then copy paste this in the files: App.xaml.cs using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices

MVVM: Communication between the Model and ViewModels

余生颓废 提交于 2019-12-04 06:03:34
I'm developing a WPF application using the MVVM pattern. I'm using MVVM Light library and I'm also trying to use a dependency injector (I'm considering Ninject and Unity). I've read a lot of blog articles and I'm quite confused about the "proper" way of making my classes communicate with each other. In particular, I don't know when to use Dependency Injection and when to rely on the mediator pattern. Lets consider an example. I have a ViewModel, lets call it DataViewModel, and the Data class that provides some kind of data. How is it better to communicate between them: A. Inject a dependency

mvvm light icleanup and messenger unregister in VB.NET

荒凉一梦 提交于 2019-12-04 05:54:58
问题 I just need a little help to clarify how the Messenger class works with ICleanup in MVVM-Light. I am creating a WPF 4 application in VB.Net with Mvvm-Light v4. I have a messenger that registers for a message sent from a NavigationService Class I created as follows: This is the registration in the ViewModel named ClientListViewModel ''register for messages Messenger.[Default].Register(Of INavigationService)(Me, "NavigationStart", False, AddressOf HandleParentChildNavigate) This receives the

How to implement IsEnabledChanged of silverlight dataform using MVVM

拥有回忆 提交于 2019-12-04 05:48:47
问题 I am looking for an example of how to implement the property IsEnabledChanged of the dataform using MVVM light, I set up the triggers but not sure about the implementation. So, here is the code behind version: void DataForm_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) { if (!IsEnabled) { VisualStateManager.GoToState(DataForm, "Disabled", true); } else { VisualStateManager.GoToState(DataForm, "Normal", true); } } DataForm.IsEnabledChanged += new

WPF MVVM cancel Window.Closing event

依然范特西╮ 提交于 2019-12-04 05:44:32
In WPF application together with MVVMLight Toolkit, I would like to see your opinion, what is the best way to implement if I need to Cancel the Window Close event. In Window.Closing event I can set the e.Cancel = true, which prevents closing the form. To identify if the Close is allowed, or should be prevented is in the ViewModel context. One solution could be if I define an Application variable, and I can query this in the normal event handler in view code behind? thanks With MVVM Light you got EventToCommand : So you could in xaml wire up the closing event to the VM. <Window ... xmlns:i=

Hook Up Command for BackKeyPress in XAML

瘦欲@ 提交于 2019-12-04 05:21:32
问题 Is there a way to hook up the BackKeyPressed event to a command in a view (XAML)? I'm using MVVM Light. I have a few login/signup screens that can possibly be shown. If they're in the login/signup process, which is just showing/hiding user controls, I want to be able to intercept the back button so I can show/hide the appropriate control. 回答1: Note that I'm not familiar with WP7 development, but I believe MVVM Light handles WPF4 & WP7 similarly: <PhoneApplicationPage xmlns:Command="clr