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

4176 questions
455
votes
15 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,092
  • 6
  • 21
  • 26
327
votes
8 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,514
  • 2
  • 16
  • 17
202
votes
3 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…
136
votes
9 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,477
  • 2
  • 10
  • 15
127
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,699
  • 3
  • 10
  • 20
112
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,125
  • 4
  • 25
  • 36
102
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…
93
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
  • 16,009
  • 27
  • 82
  • 112
92
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,569
  • 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…
83
votes
4 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.
agent47
  • 6,467
  • 15
  • 50
  • 79
80
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
  • 30,475
  • 22
  • 84
  • 129
68
votes
12 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
  • 799
  • 1
  • 5
  • 7
63
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,243
  • 2
  • 19
  • 27
59
votes
1 answer

How to bind WPF button to a command in ViewModelBase?

I have a view AttributeView that contains all sorts of attributes. There's also a button that when pressed, it should set the default values to the attributes. I also have a ViewModelBase class that is a base class for all ViewModels I have. The…
kor_
  • 1,419
  • 1
  • 13
  • 30
1
2 3
99 100