Questions tagged [viewmodel]

A view model or viewpoints framework is a framework which defines a coherent set of views to be used in the construction of an architecture. A view is a representation of a whole system from the perspective of a related set of concerns.

A view model or viewpoints framework in systems engineering, software engineering, and enterprise engineering is a framework which defines a coherent set of views to be used in the construction of a system architecture, software architecture, or enterprise architecture. A view is a representation of a whole system from the perspective of a related set of concerns.

Source: http://en.wikipedia.org/wiki/View_model

4827 questions
478
votes
16 answers

What is ViewModel in MVC?

I am new to ASP.NET MVC. I have a problem with understanding the purpose of a ViewModel. What is a ViewModel and why do we need a ViewModel for an ASP.NET MVC Application? If I get a good example about its working and explanation that would be…
unique
  • 5,442
  • 6
  • 23
  • 26
372
votes
9 answers

Ignore mapping one property with Automapper

I'm using Automapper and I have the following scenario: Class OrderModel has a property called 'ProductName' that isn't in the database. So when I try to do the mapping with: Mapper.CreateMap(); It generates an exception : "The…
Msam85
  • 3,964
  • 2
  • 18
  • 18
252
votes
4 answers

AndroidViewModel vs ViewModel

With the introduction of the Android Architecture Components library, several new classes were introduced, including AndroidViewModel and ViewModel. However, I'm having trouble figuring out the difference between these two classes. The documentation…
174
votes
11 answers

Android ViewModel additional arguments

Is there a way to pass additional argument to my custom AndroidViewModel constructor except Application context. Example: public class MyViewModel extends AndroidViewModel { private final LiveData> myObjectList; private…
Mario Rudman
  • 1,899
  • 2
  • 14
  • 18
139
votes
14 answers

Cannot resolve symbol ViewModelProviders on AppCompatActivity

Hey I'm trying to get my ViewModel working, but no luck so far. Android Studio shows error Cannot resolve symbol 'ViewModelProviders'. Every other question I found on this topic was correcting extends Activity to extends AppCompatActivity, but I…
Sheler
  • 3,969
  • 3
  • 12
  • 21
132
votes
9 answers

DTO = ViewModel?

I'm using NHibernate to persist my domain objects. To keep things simple I'm using an ASP.NET MVC project as both my presentation layer, and my service layer. I want to return my domain objects in XML from my controller classes. After reading some…
autonomatt
  • 4,393
  • 4
  • 27
  • 36
129
votes
5 answers

what is difference between a Model and an Entity

I am confused to understand what is the meaning of this words: Entity, Model, DataModel, ViewModel Can any body help me to understanding them please? Thank you all.
amiry jd
  • 27,021
  • 30
  • 116
  • 215
114
votes
5 answers

How to update LiveData of a ViewModel from background service and Update UI

Recently I am exploring Android Architecture, that has been introduced recently by google. From the Documentation I have found this: public class MyViewModel extends ViewModel { private MutableLiveData> users; public…
103
votes
4 answers

Why a viewmodel factory is needed in Android?

We have been discussing about this but we don't know the reason of creating a viewmodel factory to create a viewmodel instead of instantiate the viewmodel directly. What is the gain of creating a factory that just creates the viewmodel? I just put a…
Iban Arriola
  • 2,526
  • 9
  • 41
  • 88
95
votes
14 answers

As ViewModelProviders.of() is deprecated, how should I create object of ViewModel?

I have been trying to create an Object of ViewModel in an Activity but ViewModelProviders is deprecated So what's the alternative to create the ViewModel's object.
Anchal Arora
  • 1,081
  • 1
  • 7
  • 8
95
votes
5 answers

ASP.NET MVC Model vs ViewModel

OK, I have been hearing discussion about "ViewModels" in regards to MS's ASP.NET MVC. Now, that is intended to be a specific kind of Model, correct? Not a specific kind of View. To my understanding, it's a kind of Model that has a specific purpose…
Qcom
  • 18,263
  • 29
  • 87
  • 113
93
votes
12 answers

Two models in one view in ASP MVC 3

I have 2 models: public class Person { public int PersonID { get; set; } public string PersonName { get; set; } } public class Order { public int OrderID { get; set; } public int TotalSum { get; set; } } I want edit objects of BOTH…
Smarty
  • 1,579
  • 2
  • 11
  • 16
87
votes
4 answers

How to map View Model back to Domain Model in a POST action?

Every article found in the Internet on using ViewModels and utilizing Automapper gives the guidelines of the "Controller -> View" direction mapping. You take a domain model along with all Select Lists into one specialized ViewModel and pass it to…
82
votes
3 answers

Why do I get null instead of empty string when receiving POST request in from Razor View?

I used to receive empty string when there was no value: [HttpPost] public ActionResult Add(string text) { // text is "" when there's no value provided by user } But now I'm passing a model [HttpPost] public ActionResult Add(SomeModel Model) { …
Alex
  • 34,581
  • 26
  • 91
  • 135
76
votes
7 answers

Custom vs User control

I've been reading some explanations about the difference between User and Custom Controls, for example this: http://www.wpftutorial.net/CustomVsUserControl.html I want to create, for example, a simple composition of a datagrid with 2 comboboxes…
Louro
  • 1,413
  • 4
  • 21
  • 27
1
2 3
99 100