I found two ways to use the MV-VM pattern in WPF:
The model can be selected in the ViewModel constructor.What do you think of this way of using the MV-VM pattern? What are the best practices regarding this?Thanks you
I try to follow No. 2 and consider it the most flexible. As a best practice, I would move these DataTemplate to a ResourceDictionary so that they can be shared between XAMLs that require them.
DataTemplate
ResourceDictionary
Method No. 3 is what we do:
This is with Boo / Binsor ... datacontext is set via IOC.
component "AngleRoomModel", IRoomViewModel, AngleRoomViewModel component "AngleRoom", IRoomView, AngleRoomView: DataContext = @AngleRoomModel
Source: https://habr.com/ru/post/1310164/More articles:Getting a System.IO.FileNotFoundException exception when trying to run an application written in F # - f #Should I use jquery.getJson in 1.4.2? - jqueryHow to update a record without reselecting this record in the ADO.NET Entity Framework? - c #PHP: "Footer Function"? - phpJQuery UI Slider - input value and slider Move to location - jqueryWPF memory leak - performanceSVG parser for C ++? (Free or Paid) - vector-graphicsHow to extract metafile from TOleContainer? - delphiTStringGrid with BOTH editing and range selection? - delphiHTML: how to set children element width = browser window width? - htmlAll Articles