locked
MVVM Help RRS feed

  • Question

  • I'm developing a Windows 8.1 Store App using the MVVM Pattern, which I'm fairly new in. I've read up on MVVM through various site and such but none of them goes into how to use it when it comes to going the authentication process. I know that for the ViewModel, there would be (for example) a LoginViewModel. I would use a LoginSettingsFlyout control for the View but how do I connect the two together? Can anyone point me to the right direction as to how to get this work using MVVM Light? Thanks in advance...
    Friday, February 7, 2014 4:23 PM

Answers

  • I would suggest the following: (I am not using MVVM Light)

    - create a custom control which host your LoginSettingsFlyout control, this will be your login View.

    - create your View Model LoginViewModel.cs

    - there are many ways to connect your view to the viewModel, the simplest one is in the constructer of the LoginView.xaml.cs define the data context to be the view model:       

                this.InitializeComponent();
                this.DataContext= YourViewModel;

    Tariq

    Monday, February 10, 2014 2:35 PM

All replies

  • We have a few people using MVVM on this forum but none of the mods themselves have much/any experience in this.  You might get a better response if you post to the Silverlight/MVVM forum, which should be able to answer general MVVM questions like this:

    http://social.msdn.microsoft.com/Forums/silverlight/en-US/home?forum=silverlightmvvm


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, February 10, 2014 2:03 PM
    Moderator
  • I would suggest the following: (I am not using MVVM Light)

    - create a custom control which host your LoginSettingsFlyout control, this will be your login View.

    - create your View Model LoginViewModel.cs

    - there are many ways to connect your view to the viewModel, the simplest one is in the constructer of the LoginView.xaml.cs define the data context to be the view model:       

                this.InitializeComponent();
                this.DataContext= YourViewModel;

    Tariq

    Monday, February 10, 2014 2:35 PM