ContentControl not updating

后端 未结 3 2205
一个人的身影
一个人的身影 2021-02-10 07:28

I\'m trying to have a MainWindow that is bound to the a view. I change that view in code and expect it to update in the Main Window, however that is not happening.

I hav

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-10 07:53

    why you call your class MainWindowViewModel? when you wanna do mvvm you shouldn't have properties with type UserControl in your VM.

    the usual mvvm way looks like this:

    • viewmodel with INotifyPropertyChanged
    public class MyViewmodel
    {
        public IWorkspace MyContent {get;set;}
    }
    
    • xaml content control with binding to your VM
    
    
    • datatemplate --> so that wpf knows how to render your IWorkspace
    
       
    
    

提交回复
热议问题