Questions tagged [mvvm]

Model-View-ViewModel (MVVM) is an architectural design pattern for implementing user interfaces that separates the UI (the View) from its data (the Model) via its presentation logic (its ViewModel).

Model-View-ViewModel (MVVM) is an architectural design pattern for implementation of user interfaces. Its primary focus is on separation of concern between the View (UI) and the Model (Data) by using an intermediate layer called a ViewModel to enhance manageability, scalability, and testability.

It is used in all based frameworks including , , ,,, the ZK framework and frameworks including KnockoutJS. Popular .Net frameworks implementing the pattern include:

See Also:

29966 questions
116
votes
18 answers

Close Window from ViewModel

Im creating a Login using a window control to allow a user to login into a WPF application that I am creating. So far, I have created a method that checks whether the user has entered in the correct credentials for the username and password in a…
WPFNoob
  • 1,207
  • 2
  • 10
  • 11
112
votes
6 answers

How do I set a ViewModel on a window in XAML using DataContext property?

The question pretty much says it all. I have a window, and have tried to set the DataContext using the full namespace to the ViewModel, but I seem to be doing something wrong.
Nicholas
  • 3,286
  • 5
  • 27
  • 35
111
votes
23 answers

AngularJS browser autofill workaround by using a directive

When submitting a form in AngularJS and use the browser remember password functionality, and in a subsequent login attempt you let the browser fill in the login form with the username and password, the $scope model won't be changed based on the…
lucassp
  • 4,133
  • 3
  • 27
  • 36
110
votes
13 answers

How should I get Resources(R.string) in viewModel in Android (MVVM and databinding)

I am currently using databinding and MVVM architecture for android. What would be the best way to get string resources in ViewModel. I am not using the new AndroidViewModel component, eventbus or RxJava I was going through the aproach of interfaces…
Shubham
  • 2,627
  • 3
  • 20
  • 36
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
103
votes
5 answers

WPF OpenFileDialog with the MVVM pattern?

I just started learning the MVVM pattern for WPF. I hit a wall: what do you do when you need to show an OpenFileDialog? Here's an example UI I'm trying to use it on: When the browse button is clicked, an OpenFileDialog should be shown. When the…
Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
103
votes
10 answers

Firing a double click event from a WPF ListView item using MVVM

In a WPF application using MVVM, I have a usercontrol with a listview item. In run time, it will use databinding to fill the listview with a collection of objects. What is the correct way to attach a double click event to the items in the listview…
Emad Gabriel
  • 3,677
  • 7
  • 37
  • 49
102
votes
24 answers

Android ViewModel has no zero argument constructor

I am following this documentation to learn about LiveData and ViewModel. In the doc, the ViewModel class has constructor as such, public class UserModel extends ViewModel { private MutableLiveData user; @Inject…
Prabin Timsina
  • 2,131
  • 3
  • 16
  • 27
98
votes
4 answers

Basic concepts of MVVM-- what should a ViewModel do?

Trying to grasp the concepts of MVVM, I have already read several blogs and looked at a few projects. From what I understand, a View is dumb, it just knows how to present something that is passed to it. Models are just the plain data, and a…
RKM
  • 3,151
  • 9
  • 37
  • 50
96
votes
8 answers

Is MVVM pointless?

Is orthodox MVVM implementation pointless? I am creating a new application and I considered Windows Forms and WPF. I chose WPF because it's future-proof and offer lots of flexibility. There is less code and easier to make significant changes to…
ATL_DEV
  • 9,256
  • 11
  • 60
  • 102
89
votes
13 answers

Why use MVVM?

Okay, I have been looking into MVVM pattern, and each time I have previously tried looking into it, I gave up for a number of reasons: Unnecessary Extra Long Winded Coding No apparent advantages for coders (no designers in my office. Currently only…
Michal Ciechan
  • 13,492
  • 11
  • 76
  • 118
88
votes
5 answers

Should I bind to ICollectionView or ObservableCollection

Should one bind DataGrid to the ICollectionView = CollectionViewSource.GetDefaultView(collection) or to the ObservableCollection collection; ??? What is the best practice for MVVM and why?
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
88
votes
1 answer

How to architecture a webapp using jquery-mobile and knockoutjs

I would like to build a mobile app, brewed from nothing more but html/css and JavaScript. While I have a decent knowledge of how to build a web app with JavaScript, I thought I might have a look into a framework like jquery-mobile. At first, I…
Christoph
  • 26,519
  • 28
  • 95
  • 133
88
votes
3 answers
87
votes
14 answers

WPF loading spinner

The goal is to display the information that the application is working. So I'm looking for an intelligent implementation sample of a loading spinner using WPF / MVVM.
fabien
  • 2,041
  • 1
  • 16
  • 19