A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
ViewModel versus a ClassManager
Whilst I've been programming for years, I am learning how to use the Model-View-ViewModel Archictecture and how to integrate it and other Patterns.
I have a Class Car. I have a Class CarManager, that maintains a list of Cars. It also contains methods to handle actions on the List, such as saving to XML for example. Currently I move/reference the list of Cars in my app using an instance of my CarManager Class.
I have seen examples like this https://learn.microsoft.com/en-us/answers/questions/1468715/how-can-i-update-a-datagrid-from-another-window (thanks to Hui Liu-MSFT for the help!) where the ViewModel stores a List of Cars directly.
Should I have a reference in the ViewModel to my instance of my CarManager Class containing an observable collection of Cars, or should I just use a seperate Observable Collection of Cars? It seems a bit messy to create another list.
If I use a reference to a CarManager Instance, how would the DataBinding Change?
ie. instead of this in the CarViewModel
public ObservableCollection<Car> Cars { get; set; } = new ObservableCollection<Car>();
have
public CarManager CarManager{get; set;} = new CarManager;
(where Car Manager actually has the ObservableCollection)
Many thanks!
Developer technologies | Windows Presentation Foundation
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.