Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [mvvm]

The Model View ViewModel (MVVM) is an architectural pattern used in software engineering that originated from Microsoft as a specialization of the presentation model design pattern introduced by Martin Fowler.

Filter by
Sorted by
Tagged with
1 vote
0 answers
50 views

Correct way to store UI-specific settings in MVVM pattern

I am fairly new to MVVM. I am writing an application in which user creates a study for a physics simulation, inputs some data, runs the sim, and then views the results in graphs and tables. The ...
Justinas Rubinovas's user avatar
0 votes
1 answer
93 views

Complex stateful logic in MVVM architecture

I'm building a mobile app in Flutter, and the project has several distinct layers. The top part is something better described as MVVM: dumb View layer that performs rendering and delegates actions to ...
afrish's user avatar
  • 103
1 vote
1 answer
85 views

MVVM architecture and computations on data before presentations

I have an android app in which I am trying to follow the MVVM arcitecture. I have a Room database, abstracted by a Repository class that has methods like getAllData() which I use in my *ViewModel ...
Ait-Gacem Nabil's user avatar
1 vote
2 answers
826 views

MVVM: How and should I expose view models' models to other view models?

Many times while writing MVVM apps in C# I've come across this sort of problem where I need to expose the model in a view model so that I can get it in another view model and do something with it. ...
aelsi2's user avatar
  • 21
3 votes
0 answers
665 views

Is MVVM appropriate for a .NET MAUI Blazor hybrid app?

I am preparing to create my first .NET MAUI Blazor hybrid app. It is a relatively new technology so there aren't a ton of resources to look at, but of the ones I have found, they are all structured ...
Sudsy1002's user avatar
  • 139
2 votes
2 answers
2k views

WPF MVVM - Pass data from child-view to parent

I'm trying to implement the MVVM-pattern in a new WPF-application. I'm using the MVVM Community Toolkit to reduce boilerplate code that comes with the pattern. In my application, I'd like to have a ...
Sam's user avatar
  • 65
2 votes
2 answers
343 views

Data getter inside Model or ViewModel in MVVM

I'm working on an app I created for myself using the MVVM architecture. On my ViewModel I have a list_items that, when changed, updates the corresponding UI element on the View. The list of items ...
João Pedro's user avatar
0 votes
1 answer
149 views

Dependencies traveling through hierarchical viewmodels

Often I want to open a new window from within some view. I see opening a window as view logic. So I don't want code in my viewmodel that creates/opens/changes Windows or anything else that interacts ...
user2190492's user avatar
2 votes
1 answer
612 views

UML Diagram double arrow

In a Microsoft Learn article on MVVM there is an, what I assume, UML diagram that didn't make sense to me. (https://learn.microsoft.com/en-us/archive/msdn-magazine/2009/february/patterns-wpf-apps-with-...
Nordin's user avatar
  • 31
3 votes
1 answer
125 views

Should I have different instances of the same model in an application or just keep a single instance?

What is correct in your opinion regarding the creation and handling of models in an application let's say using MVVM, or even an MVC design pattern? I will try to illustrate the situation I see at my ...
Lucas's user avatar
  • 139
0 votes
0 answers
99 views

Models as data containers in MVVM

In the past, when I've used MVC, my model objects were just dumb data containers. Everywhere I read says that in MVVM, models should contain business logic as well as being a data container. Now that ...
Alex F.'s user avatar
0 votes
1 answer
2k views

Folder and Project Structure in MVVM for WPF Solution

I know there are already questions about file structure in MVVM but I haven't found the pros and cons for the following two structures. What would be better for a large-scale project, and why choose ...
Tiran's user avatar
  • 3
0 votes
1 answer
105 views

am I understanding MVVM correctly? [duplicate]

ViewModel has Two-way data binding with UI which means UI can access the data from ViewModel and can update the view models data. The Model has one-way data binding and is only supposed to respond ...
Saketh's user avatar
  • 9
5 votes
1 answer
311 views

Does my View Model violate the Single Responsibility Principle? Or am I just used to toy examples from tutorials?

I am a very beginner writing one of my first webapps. I'm using FastAPI and I'm stuck on the logic of creating an endpoint that has to do a lot of things before it returns something back to the user. ...
Jinx's user avatar
  • 159
0 votes
1 answer
580 views

MVVM - Wrapping Class For ViewModel

I am using a networking library I created which contains a Client class. I have a GUI which will display all these clients in a ListView with columns, such as one containing their online status. The ...
lol's user avatar
  • 113
0 votes
1 answer
1k views

Clean code and SOLID principles in WPF/MVVM view models?

I'm currently reading "Clean Code" by Robert Martin (which I should have read years ago), and it's given me a bit of a wakeup call, especially regarding keeping methods and classes small, ...
Andrew Stephens's user avatar
1 vote
0 answers
2k views

WPF Best way to create viewmodel from another viewmodel

Often I want to open a new window from within some view. I see opening a window as view logic. So I don't want code in my viewmodel that creates/opens/changes windows or anything else that interacts ...
user2190492's user avatar
1 vote
3 answers
815 views

Repository w/ MVVM Pattern: Data Format Check, Where/When, Best Practice?

TL; DR Where/When to check data format in MVVM + Repository Pattern is the best practice? Any suggestion or theory? The Scene Our team is working on an Android Project. We have a MVVM+repo structure: ...
Samuel T. Chou's user avatar
8 votes
2 answers
5k views

In MVVM, how much of the business logic should reside in the View Model, and how much should reside in the Model?

I wondered what is the "correct" or "intended" interpretation of MVVM? I worked mainly with WPF but I guess it is still relevant to all platforms embracing MVVM architectural ...
Piotr Golacki's user avatar
1 vote
0 answers
101 views

Issue implementing the Command Processor pattern using MVVM for WPF?

I'm trying to implement the Command Processor pattern using MVVM for WPF. The Command Processor pattern that I'm roughly following is the one described in the book Pattern-Oriented Software ...
redcurry's user avatar
  • 133
2 votes
1 answer
294 views

Data visualisation application for WPF and MVVM

I was wondering what is the best approach for a Data visualisation application for WPF and MVVM The key points are: The data is loaded, or needs just a little preparation such as pulling out ...
Piotr Golacki's user avatar
2 votes
1 answer
241 views

How to set up MVVM for highly dependent hierarchical objects with 3D representation

Imagine a program that designs plates with geometric cutouts. You start with a rectangular plate. A plate can have one or more rectangular depressions carved out of it. Each of these can have one or ...
Eric's user avatar
  • 121
1 vote
1 answer
2k views

RESTful web APIs using MVVM architecture

As the title implies, I would like to know if it is possible to create RESTful web APIs using MVVM architecture? Or we can use just MVC pattern to create web APIs?
Commander's user avatar
  • 113
-2 votes
1 answer
128 views

Store/Pass User data MVVM+C swift

I have an app written using MVVM and RxSwift. For navigation I'm using coordinator What is the best way to store user's credentials and pass them to Network Layer. I don't want to sore them in DB or ...
Roma's user avatar
  • 107
2 votes
1 answer
883 views

What is the MVVM way of loading images in list in Android?

Scenario: A very simple android app needed to be developed. It has just one screen with a list of items. Each item has a label and an icon. We fetch the item list from the server, and the server ...
Kashan Danish's user avatar
2 votes
2 answers
2k views

What's the better way to do MVVM with a number of very similar view models?

An important view in our application is a big table of entities. For the purposes of this question I'll use an analogy for our entities - so let's say it's vehicles. There's half a dozen different ...
KeizerHarm's user avatar
0 votes
1 answer
126 views

Does default deleting behavior of Datagrid violate mvvm pattern and separation of concerns

In WPF when Datagrid's CanUserDeleteRows property is set to true, then conveniently I don't need to implement deletion of elements from an underlying data structure. But it does mean that deletion ...
Piotr Golacki's user avatar
0 votes
1 answer
68 views

MVVM List<T> from Model to View

I am writing a control app for a 6-DOF robot. This app can send scripts to the robot, which in turn executes these and thus moves around. In the app a robotprogram can be created by adding 3D ...
Gertjan Brouwer's user avatar
8 votes
1 answer
8k views

The right place for "app logic" in MVVM context

I hope this is the right place to ask. I'm an experienced developer, and have used MVC for much time. This question is in the context of iOS/macOS development for the most part, (SwiftUI). Using MVC ...
Woodstock's user avatar
  • 191
2 votes
2 answers
6k views

How are changes propagated from the ViewModel to the Model and how often in MVVM?

I am learning the MVVM paradigm and I have seen a few different implementations surrounding the Model and how it is updated which I want to understand. My understanding of the View and ViewModel ...
Startec's user avatar
  • 157
4 votes
0 answers
1k views

Best practices for viewmodels for SwiftUI preview?

Are there best practices about how to prepare lightweight viewmodels with dummy data, that could be used in SwiftUI previews? Right now, I have a viewmodel for an in-app purchase screen, that needs to ...
Tomáš Kafka's user avatar
2 votes
1 answer
372 views

How to boost reusability and extendability in a MVVM .Net application?

I'm a software engineer that primarily writes C code but now and then makes .Net applications for fun. This is a question about the fun part. Over a duration of about 15 years, I have used and ...
Kristjan Hornung's user avatar
1 vote
1 answer
527 views

How can i handle many children viewmodels in MVVM?

Let's suppose i have a viemwodel which requires a lot of different children viewmodels. An example could be a settings menu: the main viewmodel should be able to load large number of children ...
Acerbic's user avatar
  • 69
0 votes
0 answers
506 views

In what layer should API be called in Clean Architecture - in Repository or in Use Case?

I am trying to implement Clean Architecture on my Android App with standard MVVM components. Almost every example I have found deals with simple business logic, i.e. simple CRUD operations over data ...
daneejela's user avatar
  • 201
-2 votes
1 answer
185 views

WPF MVVM using TPL - should I handle exceptions in the back or front end?

I have a WPF MVVM application, the WPF is the UI frontend and I have another project in the same solution that does DB access, I do this by starting a Task from the frontend that executes the backend ...
user14092802's user avatar
1 vote
0 answers
121 views

Should all interactions go to ViewModel?

So basically I guess I know the role of MVVM, but correct me if I am wrong View: Basically it whats the users sees + it takes user interaction Also View: It shouldn't know what the model is ... but it ...
Said Amir's user avatar
-1 votes
1 answer
975 views

MVVMCross multiple ViewModels and Views per Window

I may not being fully understanding MVVM or how MVVMCross works, but my understanding of views is that they are components of a window rather than the window itself. When you start up MVVMCross in C# ...
Jack Dane's user avatar
  • 101
1 vote
2 answers
2k views

What is the proper way to handle with View and ViewModel in WPF?

Currently, I'm making an Editor with MVVM pattern in WPF. Editor simply take an instance of a specific type as a reference and modifies it. The following code is the expected usage when editor ...
wddfrwd's user avatar
  • 61
2 votes
1 answer
930 views

Does passing a view model down to a properties violate MVVM or OOP?

I'm new to MVVM but experienced in OOP. I have an easy solution to my problem, but I'm not sure if it violates MVVM or OOP or if it is a good practice. I have a set of ViewModel classes in my WPF ...
Marvin's user avatar
  • 195
1 vote
3 answers
2k views

Extract Exception handling MVVM

I noticed a pattern in my code, where im repeating a solid amount of code. Let's say my application has 2 layers. UI and Services. I have a FileService class, that has a CopyTo method. Now there are 2 ...
Zuldaan's user avatar
  • 99
0 votes
1 answer
366 views

How do I plan my refactor of my android app for better architecture?

The current structure of my app is as follows: One activity and multiple fragments (about 25 fragments) One huge monolithic repository One huge monolithic viewmodel Databinding is being used but with ...
ericgithinji's user avatar
1 vote
0 answers
750 views

Common business logic in android MVVM

Requirement I am currently working on an android application that uses MVVM, live data and databinding. I have a use-case where I need to show a Comment button in multiple screens in my android app. ...
Anirudh's user avatar
  • 119
0 votes
0 answers
270 views

WPF MVVM EventAggregator Cons?

We have a wpf mvvm application with a lot of "panes". Just like the draggable panes in visual studio for example. All of these are individual usercontrols with their own viewmodels and im trying to ...
GradientJagger's user avatar
-4 votes
2 answers
99 views

MVVM construction questions

I am trying to understand how MVVM works. Here are two examples (in Andrdoid) on how I understand it should work, please tell me if I understood correctly. I currently want to make a list of ...
AdrienM's user avatar
  • 11
0 votes
2 answers
265 views

Should a view-model be coupled to a view or to a model?

That is, let's say I have a model that's used in several views. Should I create a single view model to represent it across all those views, or should I create a separate view model for each view that ...
ekolis's user avatar
  • 521
13 votes
5 answers
14k views

WPF UserControl Reuse With MVVM

I'm struggling to find an elegant and idiomatic way of coding the following scenario using the MVVM paradigm in WPF and was wondering how other people would approach it. I have a UserControl in my ...
Pseudonymous's user avatar
-1 votes
2 answers
886 views

Dependency relations in MVVM and the place of the controller

I know there is plenty of questions about this, but there is a lot of seemingly conflicting information. My assumption: The viewmodel is an abstraction of the view, an interface to the business ...
Esguio's user avatar
  • 3
0 votes
1 answer
238 views

CRUD actions rexponsibility in the MVVM

In Form-based application (WPF/MVVM/SQLServer), consider the form that handles the classical actions that you can perform on any entity. Create Read Update Delete The problem, in general terms, is ...
AgostinoX's user avatar
  • 841
0 votes
2 answers
195 views

Services injected with factories

I face an issue where I want to inject Entity Frameworks DbContext into a service class, in a WPF application. The problem is that the service classes are instantiated and contained by the view models....
Jakob Busk Sørensen's user avatar
0 votes
0 answers
92 views

confusion for view's and viewmodel's responsibility in mvvm architecture in android

i have a confusion about what code should be placed in view and what in viewmodel for example click events here is a snippet code of google ToDo app example for showing application architecture (...
hamid_c's user avatar
  • 197

1
2 3 4 5 6