If you want to pass data from the current model to a different view, such as a modal dialog, Avalonia/ReactiveUI: Interactions is the easiest way. If you want to share data between models, a View Model Service Locator (DI or IOC) is the fastest way from "writing the code" perspective. Observers are another valid resource but..as long as you feel like committing suicide 🙂
2:57 he creates a property for each view model 6:17 he maps the windows to the view models 9:30 you can see the needed window manager 14:07 he calls the window manager method .ShowWindow() with the view model property from the locator as the parameter
This is probably a dumb question, but what does the (???) do in the Command ("Binding Path = (???).AddItemCommand") and ItemsSource ("{Binding Path = (???).ItemsService.Items}" ? I can't get it to run because of this. It seems like a placeholder for a DataContext, but I don't see where this DataContext is defined.
The author is using Jetbrains Rider as IDE, and this text, i.e. the 'Path = (???)'-part, comes from the Rider IntelliSense, and actually it's just a suggestion. There should be nothing there. Rider just says "maybe you want to put something here (like DataContext)". So, the author is actually using Command="{Binding AddItemCommand}" but IntelliSense in Rider puts a suggestion, which confuses for those of us who are not used to Rider, that says "hey, maybe you want to put Path=DataContext.AddItemCommand instead of just AddItemCommand" and so on.
@@skylexwot Yeah, it'll be another hour or so until it's done processing, RU-vid is being really slow processing 4K footage right now for some reason, hang in there :-)
Hello, how would you do if item is an ItemModel containing 2 properties, for example LastName and FirstName, and there is an ItemViewModel taking an itemModel as parameter and having a FullName property which comes from ItemModel.LastName and ItemModel.FirstName and an IsChecked property which is not in the model and is only used to check the items so that they can be deleted. Can ServicesItems return ItemViewMod3l viewmodels directly, is this a good way of doing things?
Eh , yeah. Doing it like this you decoupled your Domain or Data Access Layer from the Presentation Layer, you could call it a frontend DTO smh. ``` public class ItemViewModel(ItemModel item ) : ViewModelBase { public string FullName => item.FirstName +" "+ item.LastName; public bool IsChecked { get; set; } = false; // default to false } ``` I 'd say you should lookup INotifyPropertyChanged and how to use it, or try out the Community.Toolkit.MVVM
Inspiraton from avalonia? You can easily do this same thing in wpf with datatemplates. The VM locator feels like a locator pattern in dependency injection 😬😬