what is difference between a Model and an Entity

The definition of these terms is quite ambiguous. You will find different definitions at different places. Entity: An entity represents a single instance of your domain object saved into the database as a record. It has some attributes that we represent as columns in our tables. Model: A model typically represents a real world object … Read more

When do I use View Models, Partials, Templates and handle child bindings with MVC 3

When should I use View Models? Is it not recommended to use the domain? I find that my view models are copies of my domain objects, and don’t see the value… View models should always be used. You should not use your domain models in the view. View models are not exact copies of the … Read more

Passing complex navigation parameters with MvvmCross ShowViewModel

I believe there may be some gremlins in that previous answer – will log as an issue :/ There are other possible routes to achieve this type of complex serializable object navigation still using Json and overriding parts of the framework, but actually I think that it might be better to just use your own … Read more

Room – LiveData observer does not trigger when database is updated

I had a similar problem using Dagger 2 that was caused by having different instances of the Dao, one for updating/inserting data, and a different instance providing the LiveData for observing. Once I configured Dagger to manage a singleton instance of the Dao, then I could insert data in the background (in my case in … Read more

ItemsControl with multiple DataTemplates for a viewmodel

You can create multiple ObservableCollections and then bind your ItemsSource to a CompositeCollection which joins those collections. Then in your XAML you can create different DataTemplates for the respective types using the DataType property which like styles gets automatically applied if it is placed in the resources. (You can also create the composite in XAML … Read more

AndroidViewModel vs ViewModel

AndroidViewModel provides Application context If you need to use context inside your Viewmodel you should use AndroidViewModel (AVM), because it contains the application context. To retrieve the context call getApplication(), otherwise use the regular ViewModel (VM). AndroidViewModel has application context. We all know having static context instance is evil as it can cause memory leaks!! … Read more

ViewModels or ViewBag?

Basically, Should everything be done through the viewmodel or is it Ok to also incorporate viewbag? Everything should be done inside a view model. That’s what a view model is. A class that you specifically define to meet the requirements of your view. Don’t mix ViewBags with ViewModels. It is no longer clear for the … Read more

How to write a ViewModelBase in MVVM

It’s worth nothing to use MVVM frameworks if you don’t know what’s going on inside. So let’s go step by step and build your own ViewModelBase class. ViewModelBase is class common for all your viewmodels. Let’s move all common logic to this class. Your ViewModels should implement INotifyPropertyChanged (do you understand why?) public abstract class … Read more