Search code examples
c#wpfxamlmvvmdata-binding

How to implement MVVM with Pages


I trying to using the MVVM pattern in c# with Pages. I am trying to set the DataContext like so

    public partial class PageView : Page
    {
        public PageView()
        {
            BindingContext = new PageViewModel();

            //etc

But BindingContext doesn't exist.

What's the correct way to do this for pages?


Solution

  • It should be

    DataContext = new PageViewModel();