Question

I want to create help in my Widnows Store app. I'm using MVVM pattern. I found this: http://msdn.microsoft.com/en-us/library/windows/apps/jj649425.aspx

I have completed control XAML, but i don't know how to do this:

private void MySettingsBackClicked(object sender, RoutedEventArgs e)
    {
        if (this.Parent.GetType() == typeof(Popup))
        {
            ((Popup)this.Parent).IsOpen = false;
        }
        SettingsPane.Show();
    }

in mvvm way.

Was it helpful?

Solution

This is the very common confusion about the MVVM pattern that there should be no code in Page.xaml.cs but this is not the case. Actually MVVM pattern means that your logic part that does not depend on your UI must be in your ViewModel of that Page.

So for example if you setting visibility of some control on click on some Control so there is noting wrong about that under this pattern. That's why messenger class is there if you want to send some notification or message you can use that.

So in your case everything is prefect so just use a messenger class of MVVM and send the information of parent control if want to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top