[WPF]How to binding in the UserControl.xaml at the same time load UserControl.xaml UI?
I'm using the wpf-ui template to use the wpf mvm pattern. I focused on 4 files I want to use DashboardPage.xaml, DashboardPageViewModel.cs , User.xaml, UserViewModel.cs . I want to get the ui of the UserControl file User.xaml from the Page file DashboardPage.xaml. By the way, I implemented a code that allocates datacontext to the behind code to implement a button-like control function in User.xaml. Of course, I implemented the same code that allocates DataContext to the DashboardPage.xaml.cs behind code. The problem is that the code implemented by User.xaml.cs causes the "Object reference not set to an instance of an object." error. I wonder why the problem occurred.
*picture 1 is error cature. **picture2 is that if annotate ViewModel assign part and DataContext assign part in the User.xaml.cs , then no happened error. but this is not what i want. I wanna implement control at the UserControl.xaml ( User.xaml)