mvvm-light

In MVVM, how do I distinguish between user changes and system changes to the view model?

 ̄綄美尐妖づ 提交于 2019-12-08 09:01:51
问题 I've found that the common way of defining view models doesn't differentiate between changes by the user and changes by the system. For example, public class PersonViewModel : ViewModelBase { private string _name; public string Name { get => _name; set => Set(ref _name, value); } } Here, the PropertyChanged notification will be raised if the user changes the name in the view. But it will also be raised if the application changes the property for some reason (for example, during initialization

MVVM Light and windows phone RTW any gotchas

此生再无相见时 提交于 2019-12-08 06:05:21
问题 Are there any gotchas using mvvm-light and the RTW windows phone 7 tools? There was a hotfix back in July but is there a new one in the pipeline? 回答1: The changes between the Beta & Release version don't have any major changes comparable to those introduced in the move from CTP (Refresh) to Beta. Hopefully MVVM-Light is without impact, but it's still officially a Beta so expect a release version to come - hopefully quite soon. Of course if you find any issues as a result of the change to RTM

WPF & MVVM Light - Closing a specific child window via Messenger

放肆的年华 提交于 2019-12-08 05:57:50
问题 In my project I am able to open multiple child windows, display and return information from them, and then close them with a button click. The problem that I am having is that clicking the "Accept" or "Cancel" button closes all open windows. I need to find a way to only close the correct window and I haven't been able to figure out how. I am using MVVM Light and I'm thinking tokens may be the key but I haven't figured out how to make them work. If anybody could help me I'd greatly appreciate

Registering for messages outside of a ViewModel in MVVM Light?

岁酱吖の 提交于 2019-12-08 01:42:59
问题 I was trying to register for a message outside of a ViewModel in a static constructor but apparently that registration didn't take: the registered action never ran when messages were sent. I tried passing in null or a new object for the recipient parameter when registering but that didn't work. I have a feeling the specifying the recipient must be important somehow, but I don't know why. I thought that all recipients were supposed to get broadcasted messages anyway. Is there a way to make

Is it safe to call new RelayCommand (ICommand) in Expression-Bodied Properties

寵の児 提交于 2019-12-08 01:24:20
问题 With expression bodied properties we can create a RelayCommand as follows public RelayCommand Command => _command ?? (_command = new RelayCommand(CommandExecute)); However this is possible also public RelayCommand Command => new RelayCommand(CommandExecute); Obviously this creates a new RelayCommand every time the Property getter is called. Though there is comments i have seen around that says the underlying plumbing only creates one command... Does anyone have a definitive answer on this?

MVVM Light - Relaycommand with Pushpins

一曲冷凌霜 提交于 2019-12-07 18:21:39
问题 I am data binding some pushpins to a MapLayer. They display fine, but when I use the relaycommand to pass the eventargs from the mouse leftbuttonUp, the object sources is an elipse. I have used this method on a MapPolygon and picked up the information I wanted from the object. Maybe I am aproaching this badly as I am new to mvvm, so please let me know! This works for my MapPolygons (vm references the namespace of my extendedMapPolygon class) <DataTemplate x:Name="polyTemplate"> <vm

How can MVVM Light be used in a WPF User Control Library project?

点点圈 提交于 2019-12-07 17:26:54
问题 Specifically, I would like to know how the view model is to be bound to a user control. The examples I have been able to find so far are all WPF Application or WPF Browser Application projects. Even the templates in tool kit are for WPF Application or WPF Browser Application projects. I am using Visual Studio 2010. 回答1: Found the ff. in the comments of MVVM Light's site: http://blog.galasoft.ch/posts/2010/03/whats-new-in-mvvm-light-v3/. Basically, in lieu of App.xaml, the view model locator

WP7 recover from Tombstone and return to page

て烟熏妆下的殇ゞ 提交于 2019-12-07 14:33:52
问题 Is there an nice / elegant way to get back to the page a user was on when recovering from a tombstone? I'm not sure if my app or its just the way things work, but I always end up back on my Main page. My app is setup with a main page that has a Pivot Control and several of the Pivot Items will navigate to new pages. My Naigation looks something like this if it makes sense: PivotItem1 -> PageA PivotItem2 -> PageB -> PageC PivotItem3 -> PageD -> PageE - PageF (Pressing Back Button on PageF will

ViewModel doesn't receive message in MVVM Light

£可爱£侵袭症+ 提交于 2019-12-07 14:10:28
问题 I have two ViewModels: MainViewModel and QuestionViewModel. I Register they in ViewModelLocator. SimpleIoc.Default.Register<MainViewModel>(); SimpleIoc.Default.Register<QuestionViewModel>(); On MainViewModel I have a ListBox with Questions. When Click I execute this command NavigationService.NavigateTo(new Uri("/Pages/QuestionPage.xaml", UriKind.Relative)); Messenger.Default.Send<Question, QuestionViewModel>(q); QuestionPage's DataContext set to QuestionViewModel. On QuestionViewModel I

MVVM-Light Toolkit — How To Use PropertyChangedMessage

狂风中的少年 提交于 2019-12-07 11:47:02
问题 Can someone please post a working example of the PropertyChangedMessage being used? The description from the GalaSoft site states: PropertyChangedMessage: Used to broadcast that a property changed in the sender. Fulfills the same purpose than the PropertyChanged event, but in a less tight way. However, this doesn't seem to work: private bool m_value = false; public bool Value { get { return m_value ; } set { m_value = value; Messenger.Default.Send(new PropertyChangedMessage<bool>(m_value,