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
4
votes
2answers
8k views

How to separate the ViewModel from the Model, yet associate them with each other based on the Model?

In a wpf application, a Model object is created either from scratch or deserialized from some .xml file. To create a connection to the ViewModel, the following method (on the Model!) is used by the ...
3
votes
1answer
2k views

MVVM communicate between views

I know we can use the Mediator Pattern to communicate between view models but what about views? Lets assume I have a button in View A which should trigger functionality of View B. How is this ...
4
votes
1answer
710 views

MVVM Persistence from view model

I'm new to MVVM, I get the general idea, but there's one thing that I've been having a tough time finding an answer for. Inevitably an application will have a save button in the UI. The UI talks to ...
0
votes
1answer
93 views

MV(X) Patterns: How much nesting is too much? Is not enough?

Posts may be smaller than they appear! Skip the bulleted list. Lemme Just Say... I know that this is going to be largely (entirely...) opinion-based. Everyone has their own approach, and their own ...
1
vote
1answer
233 views

WPF – Arrangable row of rectangles

I originally posted this on StackOverflow, but got the message that this was the correct forum for such a question. https://stackoverflow.com/questions/44077183/wpf-arrangable-row-of-rectangles. I am ...
0
votes
2answers
2k views

Distinguishing the differences between view model and service layer

First project trying to use MVVM and Xamarin Forms, so please be gentle; however, I am at a lost on how to differentiate between the logic that belongs in the view model and model/service layer. I am ...
2
votes
1answer
261 views

MVVM, example of use in iOS

I have a view controller with a mapview (Apple Map), on top of that there is a view with a button and a textfield. The view is compacted around the search button, when I touch it it expands revealing ...
0
votes
1answer
3k views

Multithreaded C# MVVM Application Architecture

I have an application built in C# using the MVVM pattern that will have 40-50 different tests that need to be run. I want to show each test as a list item with a progress bar of how far each test has ...
5
votes
2answers
599 views

Should I remove “everything” from my controller in MVVM?

I'm working with Xamarin and we are following the MVVM design pattern. For those who don't know what Xamarin is, it's a technology that allows us to build iOS and Android apps with shared code. ...
1
vote
1answer
105 views

If I have to check integrity of the strings coming from the View, where should I do it?

The scenario: I have a GUI with textfields and radio buttons where the user insert information for a 'Person' Here are the classes of the model and of the view-model: enum Gender { case Male, ...
-1
votes
1answer
2k views

Can MVVM architecture be used in designing web applications?

One of the client for whom I had worked has a MVVM architecture for web application.I dont know why they incorporated instead of MVC. is this a feasible idea because as far as I have gone through all ...
1
vote
2answers
2k views

Preserve MVVM while using XAML resources

Context: I'm creating a WPF application using MVVM. I have a Page which displays a status informing what task the app is performing on Background. I have a container, and bind its Content to an ...
1
vote
1answer
649 views

MVVM, is it better suited for web applications or GUIs?

I am currently deciding whether I should implement a new system with a web application as a front-end, or if I should instead produce an executable file using WPF. The pattern that I will use is MVVM,...
0
votes
1answer
2k views

Is MVVM the right choice for a single-developer WPF project?

I'm starting to design and develop a WPF application for my company and one of the first choices that I have to make is whether or not to use MVVM. The main points to consider are: The application ...
2
votes
1answer
3k views

When using MVVM, is it okay to use property injection on a view model in WPF?

I am rather new to the concept of MVVM in C#/.NET WPF projects. The way I understand it, the view-model is supposed to lessen the amount of code-behind required to display data on a form. I try to do ...
5
votes
2answers
222 views

Should I create a (new) project for shared UserControls?

Context: I'm creating some applications to help me on my daily tasks, it does not connect anywhere and the only "data" it has to deal with is the parameters that I enter on the input fields. This is ...
3
votes
1answer
597 views

MVVM Inheritance following SOLID principles

I'm currently at the design phase of my program (hence no code). It will be written in WPF in C# using MVVM principles. I'm going to have a multifunctional Drag & Drop control, that will act ...
5
votes
1answer
2k views

MVVM best practices with WPF client and WCF duplex service

I've been thinking about how to design my WPF application, which receives data from a WCF duplex service, but I'm afraid of over engineering. I thought about abstracting away the WCF communication ...
3
votes
1answer
358 views

CQRS: how granular should the queries be?

I have a system that uses CQRS with the Queries written using Dapper. It's worked out well, except that there has been a proliferation of query classes that do almost the same thing. The downside of ...
3
votes
2answers
852 views

State handling in WPF-MVVM

I am looking for advice on handling states in a WPF MVVM environment. As an example, assume we have A TreeView (or some other ItemsControl) with some items and a button that is enabled when an item ...
10
votes
2answers
8k views

In MVVM, should ViewModel or View be responsible for creating new views?

In my WPF application, I want to create a new view. Where should I do that - in ViewModel or Model? The application is a (very simple for now) one-window form-like tool with single "send" button. In ...
2
votes
2answers
1k views

Invoke model logic in one UserControl from view-model in another UserControl without violating MVVM

Here is WPF application consisting from 3 UserControls: UserControl3 is a part of UserControl2 content. I keep MVVM during developing and using Prism. I need to invoke custom class method (which is ...
1
vote
1answer
68 views

How to test dynamically created HTML when the tests are in a separate file?

Code context I have a complex page as part of my web app that is dynamically populated with information using knockout.js. The page has dynamically created anchor tags that link to each other. For ...
0
votes
1answer
1k views

MVVM Model vs. DDD Entity

I have just stepped into the Domain Driven Design paradigm but I have one question: How is an MVVM Model different from a DDD Entity? What are the differences between these two?
0
votes
1answer
315 views

How to properly organize multiple WPF/Entity Framework applications that share resources?

Company A is building 5 separate in-house WPF applications, and they would like to share UserControls, ResourceDictionaries, and ADO Entity Data Models between each project. They would also like to ...
2
votes
3answers
835 views

Including the type name in a variable name

Abstract: Is it acceptable to include the type name in the variable name? My scenario: I am working with C# MVVM, and I have a lot of ICommand properties in my ViewModel, named various things like ...
1
vote
1answer
619 views

MVVM with DI, view model location and shared service data

I have a couple of questions regarding MVVM view models. I have 3 view models in my scenario, which I have put together a shorter sample below. I was looking for a nice solution for 3 views working ...
1
vote
2answers
1k views

Where to call OnPropertyChanged

With WPF and MVVM, properties of the ViewModel are bound to UI elements. When a property changes, its set accessor calls OnPropertyChanged which in turn raises the PropertyChanged event of the ...
2
votes
1answer
799 views

JavaScript - Client-side separation of Model and ViewModel?

I am developing web apps using the Model-View-ViewModel approach with Knockout.js. After reading on the original introduction of MVVM by John Gossman, I realized that my ViewModel always contains ALL ...
1
vote
1answer
1k views

Alternative to ObservableCollection in c# wpf MVVM

I am new to wpf c# and MVVM approach. I have a working program that demonstrate the MVVM approach in wpf c# (by copying some code from the internet and applying it to may program). I have used ...
7
votes
3answers
7k views

MVVM Commands - one command for everything or multiple commands?

In my last company, on handling view commands, in the ViewModelBase there were one central command implemented, like public ICommand ToolCommand { get; set; } And in the ViewModelBase, it's been ...
0
votes
2answers
1k views

Stateless vs Stateful ViewModel

Here are two links which briefly describe the difference between the two: stateless, stateful In short in the "Stateless" scenario we bind views directly to models, view models just expose the whole ...
1
vote
0answers
1k views

MVVM approach to mahapps.metro Dialogs

I want to use a ShowMessageAsync method, but, at first sight, there is no obvious way to do ViewModel binding, even though there are already a certain number of answers and examples about this. Now, ...
19
votes
1answer
4k views

Is there a good formal pattern to manage state in MVVM?

I have started learning about Redux and React in the web-world, and the more I learn about it the more I'm realizing how painful state management is in the desktop-world with WPF's MVVM-style ...
1
vote
1answer
964 views

Recommended approach to initialize Command

I've two commands in my View Model and one of them is initialized using lazy loading and other using eager loading. Which approach is good to go? Should I use lazy loading or eager for both? View ...
1
vote
0answers
696 views

How to manage dbContext in a multi-user application?

I put together my first line-of-business app using WPF/MVVM/EF6(db-first)/MSSQL and realised that multiple users could not see each others' changes because I was using one dbcontext and keeping it ...
2
votes
2answers
313 views

SQL - Design concepts - Relationships - Referential Integrity - Cascading

THE SCENARIO I learned about basic database design concepts such as basic CRUD operations, referential integrity, relationships, etc., years ago. I've messed around with databases and used this ...
3
votes
4answers
1k views

Multi-screen MVVM architecture/design - Should my “screen” ViewModels contain sub-ViewModels?

I'm getting beyond a simple MVVM program now, and I'd just like to sense check my current architecture and makes sure I'm going down the right path here. Everything is structured around screens, and ...
4
votes
3answers
2k views

Is using getters in XAML view-models a bad thing?

I've recently had an argument with a colleague about using getters (without setters) in a view-model classes used by XAML. Example: public string FullName { get { return $"{FirstName} {...
5
votes
1answer
8k views

Mapping Domain models to ViewModel

I have an Asp.net MVC5 application structured like this: Core Domain project Infrastructure DAL project Utilities UI UI project (contains ViewModel at the moment, will probably put that into ...
0
votes
1answer
725 views

Create an item in two different table with auto-increment C# SQL [closed]

First of all, let me apologize because I know my question will be very confusing since my English is pretty bad. I am working on a project for a company, mainly create a system to take care for ...
2
votes
1answer
3k views

Passing MVVM objects to other classes [closed]

So I'm using C# WPF and binding to a Model View to display states. The data that needs to be displayed is spread across a couple different classes. For instance I have a class that reads out digital ...
2
votes
1answer
6k views

Best practice to extend Model in View Model

I'm facing an issue where I have a Model which I want to implement a GUI for. As I'm exploring MVVM and WPF I will of course use a View Model between the View and Model. I will also have a need to add ...
0
votes
1answer
1k views

Switch complex WinForms app to WPF MVVM

This question is connected with my older question C# Application GUI design dependent on configuration. I have built quite big WinForms application working in industry for a few years. It ...
2
votes
1answer
519 views

MVVM viewmodel to view correlation in adaptive UI

I am making an mvvm application for the uwp platform and I am looking for advice on the following matter. Take for example the windows 10 e-mail application, which when full screen displays both the ...
5
votes
2answers
6k views

C# .NET MVVM software architecture and naming conventions

I am currently working on a software using C# .NET and WPF with the MVVM pattern. Though the software is almost done, I have been discussing our architecture for a long time and I would like to get ...
6
votes
3answers
865 views

Modular Filter Architecture for WPF

I am creating a little stock-management tool for private use. I have different views, which need similar but different filters. As an example I have a "current stock" list where I can filter for ...
1
vote
1answer
339 views

What are potential problems when write business logic code in GUI as MVVM pattern

Currently, I'm implementing MVVM pattern for a WPF application but not 100% no code behind, sometimes I put some business logic code into GUI and so what are potential problems for this? Thanks
4
votes
1answer
1k views

Who is responsible for setting color in MVVM?

I have an iOS app where after exceeding a certain limit, part of the user interface changes a color to alert the user. I'm using MVVM to accomplish this and division of labor looks like this: Model - ...
3
votes
1answer
2k views

Usefulness of the Command CanExecute as it exists in WPF

I want to question the usefulness of the CanExecute functionality in WPF (defined in the ICommand interface). As I think that you can achieve the same functionality thing without this feature I ask ...