mvvm-light

MVVMLight and Data Serialisation

前提是你 提交于 2020-01-14 03:04:08
问题 I'm getting started with MVVMLight for a Windows 8 Store app. I've got the basics working after viewing some videos. however I have run into an issue. Each of my base model classes inherit from ObservableObject in MVVMLight. This was working fine but I now want to load and save data to XML. So I marked them with DataContract attribute which I'd used previously in a non MVVM implementation. However this now creates an error when serialising as it says my inherited classes must also be marked

One Model Entity, Multiple Pages -> Multiple Views? Multiple ViewModels?

 ̄綄美尐妖づ 提交于 2020-01-13 19:27:29
问题 Due to limited screen real estate I will be capturing user input for a single entity using multiple pages (displayed consecutively - think wizard). In my model I expect it is correct to model this entity as a single class. In an MVVM implementation I am assuming it is best MVVM practice to consider each page as a seperate View. Is this correct? Is there a consensus on the best MVVM practice for whether each Page has it's own ViewModel or should there be one ViewModel instance that is

WPF MVVM cancel Window.Closing event

大兔子大兔子 提交于 2020-01-12 18:48:36
问题 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 回答1: With MVVM Light

WPF MVVM cancel Window.Closing event

妖精的绣舞 提交于 2020-01-12 18:48:24
问题 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 回答1: With MVVM Light

Managing Multiple Views/ViewModels In A Single ContentControl

邮差的信 提交于 2020-01-12 08:47:12
问题 I have an application which shows a single View at a time in a ContentControl. I have a current solution, but was curious if there is a better one for memory management. My current design creates new objects when they need to be displayed, and destroys them when they are no longer visible. I'm curious if this is the better approach, or maintaining references to each view and swapping between those references is better? Here is a little more explanation of my application layout: A very

MVVM conform localization in WPF Applications

末鹿安然 提交于 2020-01-12 03:17:38
问题 How can I localize an WPF Application using the MVVM Pattern? I really want to do it the "right" way. My current approach is that I use .resx Resource files to localize my application. I included them in my xaml code xmlns:localization="clr-namespace:ClientLibTestTool.ViewLanguages" and access them like this: <Button x:Name="BtnGenerate" Content="{x:Static localization:localization.ButtonGenerate}"/> My Questions: Is there a better way to do it? How can i test the different languages (load

Handling Mouse Events in MVVM in WPF

孤者浪人 提交于 2020-01-11 18:34:44
问题 I am Using MVVM with WPF. i am halted in a way, i want your views about this. i am firing Mouse Events using MouseBehaviour.cs class , Is there any other way to handle Mouse Events in MVVM WPF using System.Windows; using System.Windows.Input; namespace Lovatts.MouseBehaviours { public class MouseBehaviour { #region MouseUp public static readonly DependencyProperty MouseUpCommandProperty = DependencyProperty.RegisterAttached("MouseUpCommand", typeof(ICommand), typeof(MouseBehaviour), new

Handling Mouse Events in MVVM in WPF

放肆的年华 提交于 2020-01-11 18:33:05
问题 I am Using MVVM with WPF. i am halted in a way, i want your views about this. i am firing Mouse Events using MouseBehaviour.cs class , Is there any other way to handle Mouse Events in MVVM WPF using System.Windows; using System.Windows.Input; namespace Lovatts.MouseBehaviours { public class MouseBehaviour { #region MouseUp public static readonly DependencyProperty MouseUpCommandProperty = DependencyProperty.RegisterAttached("MouseUpCommand", typeof(ICommand), typeof(MouseBehaviour), new

How to change startup page on WP7 application

半世苍凉 提交于 2020-01-09 07:48:48
问题 I want to have different start-page depending on if there is some settings stored in IsolatedStorage. Bu I don't know where the is the best practice to handle this. I.e if I find something in isolated storage I whant the user to get MainPage, otherwise I woluld like the user to get Settings-page. I'm using MVVM-light if there is some magic stuff to use. Br 回答1: You can do this by setting a dummy page as the main page of your project. You can change the main page by editing the WMAppManifest

Get Navigation data in View Model Windows phone 8

家住魔仙堡 提交于 2020-01-07 04:23:39
问题 I'm using Mvvmlight INavigationService in the project, from view model I navigate to a view , and pass object as parameter ,how do I get either in the view model or in the code behind. I have implemented based on this My View model locator private static INavigationService CreateNavigationService() { var navigationService = new NavigationService(); navigationService.Configure("topupdetails", new System.Uri("/Views/TopUpDetails.xaml", System.UriKind.Relative)); return navigationService; } View