mvvm-light

MvvmLight in Portable Class Library - How to do Unit Testing

守給你的承諾、 提交于 2019-12-11 00:44:35
问题 I'm working on the windows store application and I met one big problem. I described my solution architecture some time ago in this question. I added MvvmLight to my portable class library containing the presentation logic and afterwards I tried to write unit tests to one of my ViewModel inherited from ViewModelBase (from MvvmLight). Problem is, that portable class library has referenced MvvmLight package of another version like in the classical UnitTest .NET 4.5 class library and that means I

NavigationService throws NullReferenceException

血红的双手。 提交于 2019-12-10 22:21:29
问题 Using MVVM Light, I'm trying to develop a rather simple WP7 application. I've run into a problem using the navigation service. I can navigate to a page, but after pressing the back button I can't navigate to the same page again. NavigationService throws a NullReferenceException. I have implemented my navigation using Messaging from the GalaSoft.MvvmLight.Messaging namespace. All my views inherits from a customized PhoneApplicationPage base class that registrers a listener on

how to avoid click when I want double click?

本秂侑毒 提交于 2019-12-10 21:53:02
问题 I have an application in WPF and one button. In this buttun I want the click event that implement a code, but I want that when the do double click with the mouse, execute other code but not the code of the click event. The problem is that the code of the click event is always executed and I don't know if there is a way to avoid the execution of the click event when I do doulbe click. I am follow the MVVM pattern and I use MVVM light to convert the event into a command. Thanks. 回答1: Set the

How to send message to one view of many

孤街醉人 提交于 2019-12-10 20:42:34
问题 I have an app that presents many view-viewModel pairs based on the same view and viewModel. (ie there are many view -> viewModel instance pairs) I can use the Messenger to send/register messages from viewModel to view, and when I send a message from a view, it is processed by all the views (They all register for the message). How would I use the Messenger to send a message from the viewModel to the specific view that created the viewModel? (All the views have registered for the message, but I

Unable to access viewmodel properties from inside Listvew.Resources

﹥>﹥吖頭↗ 提交于 2019-12-10 18:29:46
问题 I'm trying to bind the SelectedItem to a View. But the view is not able to access the viewmodel when it is inside the Resources block. When the datacontext is re-assigned to the children, the binding works for textblocks but not for UserControl (NoteView) Am I missing any Binding? PFB revised(entire) code and inline comments. <UserControl x:Class="Konduva.View.NoteSearchView" <!-- other namespaces here --> xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"

WP MVVM Navigation OnNavigatedTO

浪尽此生 提交于 2019-12-10 17:46:36
问题 I am starting to implement MVVM in my application and got an issue of knowing when the user navigated to the view. To navigate between views, I can just use the navigationService.Navigate(...); How do I check when I navigated to the view? May I use the event navigationService.Navigated ? Is there no other method I can use like OnNavigatedTo that the page itself provide? 回答1: XAML: xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr

ObservableCollection in ViewModel is not updated when a List changes in Model

时光毁灭记忆、已成空白 提交于 2019-12-10 17:42:20
问题 Let's say I have a model class Data and I would like to create DataViewModel and DataView for it. The data class looks like this: public class Data { public Data() { RandomData = new List<String>(); } public List<String> RandomData {get; set;} } I want to create DataViewModel that encapsulates RandomData property. I need to bind to that RandomData property in some ListView and have it updated when the underlying model's RandomData changes. If I do this: public class DataViewModel { private

How to trigger an EventToCommand from a GestureListener.Gesture

久未见 提交于 2019-12-10 16:52:29
问题 Has anyone used a Toolkit.GestureListener to fire an EventToCommand? 回答1: I don't think you can do it with the EventToCommand behaviour but I have created a behaviour that allows easy addition of the GestureListener by binding them to a command. <Button Content="Start" Behaviour:GestureListenerBehaviours.TapCommand="{Binding StartCommand}" /> I have only mapped the tap and the double tap but it should be easy to map the rest if required. Have a look at this link to get the source code http:/

Keydown event: how to capture down and up key rows?

血红的双手。 提交于 2019-12-10 16:14:11
问题 I am trying to capture the down and up keys (the direction rows) but when I press this keys, it is not raised the event keydown. However, if I press any other key, the event is raised. For example numlock is catched. The row keys are special keys? I am using MVVMLight to convert the events to command, and pass the KeyEventArgs. Thanks. EDIT: add some code Well. really I have a comboBox, and is editable, so I can write text inside the comboBox. How the search option is enabled, while I am

MVVM and NavigationService

自作多情 提交于 2019-12-10 15:27:45
问题 One of the many benefits of implementing any pattern is to have a separation of concerns between the different layers in an application. In the case of Silverlight and MVVM it is my opinion that the NavigationService belongs to the UI. If the NavigationService belongs to the UI then it should be used in the XAML code behind, but the commands happens on the ViewModel. Should I raise an event on the Command in the ViewModel and let the View handle the event and call the Navigation? That sounds