How to attach a ViewModel to a UserControl? In the case of window, I always did this:
new MainWindow() { DataContext = new MainVm() }; If you do so for UserControl, the compiler swears. How to act in this situation?
PS For the overall picture I will explain what effect I am aiming at: there is a main window, and depending on user clicks, different, unrelated data should be displayed. Therefore, for each of these data, I want to create separate UserControl and Vm, and, if necessary, just replace one UserControl with another. If I have the wrong approach, correct me.