Contents
Should a ViewModel in MVVM reference the view?
Reed and Dan covered the general approach but in reference to your specific case, TabControl is an ItemsControl and so can bind its ItemsSource to a data collection in your ViewModel representing the set of tabs to display.
How to do usercontrol dependency property and MVVM?
The XAML of your control right now reference the property TextInTextBlock via the DataContext which in turn “Points” to your main window’s view model. Reference the data of the control and you are done (btw do not set the DataContext for that reason – the binding won’t work any more): This is how I do UserControls with MVVM and DP binding.
How to implement INotifyPropertyChanged in a ViewModel?
Here’s some code (the viewmodels use some kind of mvvm-framework that implement the INotifyPropertyChanged in a ViewModelBase-class but that’s hopefully no problem): CodeBehind MainWindow.xaml.cs: MainWindow-ViewModel MainWindowVM.cs: And here the UserControl1.xaml: The Codebehind UserControl1.xaml.cs: And the Viewmodel UserControl1VM.cs:
How to do usercontrols with MVVM and DP bindings?
This is how I do UserControls with MVVM and DP binding. It’s similar to Rohit’s answer but with some slight changes. Basically you need to set the Control’s internal view model to be the DataContext of the root container within the UserControl rather than the UserControl itself, that way it will not interfere with DP bindings.
What is the role of the controller in MVC?
Controller: it is really the heart of the MVC, the intermediary that ties the Model and the View together, i.e. it takes user input, manipulates the model & causes the view to update The User Information Manager is an application where you can store your customers’ contact information.
Can you use MVC for a desktop application?
Even though it is for the web and not the desktop, understanding what problems ASP.NET MVC is solving by using the MVC pattern will help you to understand how to best implement a solution for the desktop. You also might consider looking for suggestions on implementing the MVC Pattern with WPF or Silverlight.
Is there a head first design pattern for MVC?
I know that Head First Design Patterns includes an introduction to the MVC pattern. You may consider exploring ASP.NET MVC. Even though it is for the web and not the desktop, understanding what problems ASP.NET MVC is solving by using the MVC pattern will help you to understand how to best implement a solution for the desktop.