model-view-viewmodel

How verbose should names be for Model-View-ViewModel (MVVM) classes and instances?

In general, I prefer to be verbose with .NET class and instance names, but some times (to quote Mike Woodhouse): Over-verbosity tends to conceal syntax, and syntax is important. The first place I felt like I really strayed into the over-verbosity regime is upon implementing the Model-View-ViewModel (MVVM) pattern in Silverlight and...

What are the biggest pain points with the ViewModel pattern?

Glenn Block and I have been working together on the ViewModel pattern. We’ve been trying to identify the biggest pain points associated with the pattern, with the goal of adding framework support to alleviate the pain. Tonight, Glenn posted, “View Model” – the movie, cast your vote. We want to hear from you. Please post here (and vot...

How to set up Header/Lines in WPF/Silverlight

Hi, Do you have any best practices for setting up Header/Lines forms (Also known as Header/Details) in WPF or Silverlight? Preferably using the Mode-View-ViewModel design Pattern to fit in with the rest of my application. An example would be if I had a grid that displayed all SalesOrders in the database, and the underneath that a grid ...

When to use a ViewModel rather than a Model?

I have a business model called Customer which has many required properties (via DataAnnotations) and other validation rules. I have a View which is meant to allow editing of the customer's address fields. The problem I have is that I want a strongly-typed view but I can't get away with using the Customer type here. Since the view will...

WPF Binding: Refreshing Binding after reload of combos from database

I've got two combo's 'Make' and 'Model', they've got their SelectedValue properties bound to an Vehicle object with a ModelID and a MakeID. Heres Model ... <ComboBox DisplayMemberPath="Description" ItemsSource="{Binding Path=ModelSpecs}" SelectedValue="{Binding Path=Vehicle.ModelID}" SelectedValuePath="ID" /> A user can search for Ve...

WPF ICommand MVVM implementation

So in this particular MVVM implementation I'm doing, I need several commands. I really got tired of implementing the ICommand classes one by one, so I came up with a solution, but I don't know how good it is, so the input of any WPF expert here will be greatly appreciated. And if you could provide a better solution, even better! What I ...

ASP.NET MVC, Model and ViewModel separation of concerns?

Hello, Lately, I've been exploring what's the best way to organize presentation layer of ASP.NET MVC application when underlying Model is complex. What came up till now is MVVM architecture with their ModelView objects. However, I'm not sure what are the best practices when this kind of architecture is in case. Does ModelView objects ...

ViewModels and rendering

In several sample projects, I've seen ViewModels being used to convert data objects into strings, for use in the View. The ViewModel will typically have a constructor that receives one parameter - a data object. The constructor will then populate various properties of the ViewModel (mostly strings and ints). This prevents any complex l...

Resources for implementing MVVM (ViewModel) pattern in Flex?

Can anyone direct me towards some code or a tutorial for implementing the ViewModel in Flex 3? All I'm finding on the web are examples for Silverlight. ...

Complex Filtered Parent-Child LINQ to SQL Query

The title and tags of this post may be incorrect since my solution may end up being more MVC Controller - Model related instead of LINQ related... I am building an MVC (not that the platform is important) site to display Invoices and the Invoice Details for approval before being paid. Basically this gives me a standard Master-Detail dat...

Commanding in MVVM (WPF)--how to return a value?

I've been using MVVM pattern for a while now, but I still run into problems in real-life situations. Here's another one: I use commanding and bubble up the event to be handled in the ViewModel. So far, so good. But the project for which I'm using MVVM is actually a class library. Once I run the command code, I need to be able to send...

ViewModel with SelectList binding in ASP.NET MVC2

I am trying to implement an Edit ViewModel for my Linq2SQL entity called Product. It has a foreign key linked to a list of brands. Currently I am populating the brand list via ViewData and using DropDownListFor, thus: <div class="editor-field"> <%= Html.DropDownListFor(model => model.BrandId, (SelectList)ViewData["Brands"])%> ...

Is there a way to update a ViewModel in MVC2?

This code works: [HttpPost] public ActionResult Edit(int id, FormCollection fc) { Movie movie = ( from m in _ctx.Movie.Include("MovieActors") where m.MovieID == id select m ).First(); MovieActorViewModel movieActor = new MovieActorViewModel(movie); if (TryUpdateModel(movieActor)) ...

How to handle One View with multiple ViewModel and fire different Commands?

Hi All, I have senario in which one view and view has binding with multiple ViewModel. Eg. One View displaying Phone Detail and ViewModel as per bellow: Phone basic features- PhoneViewModel, Phone Price Detail- PhoneSubscriptionViewModel, Phone Accessories- PhoneAccessoryViewModel For general properties- PhoneDetailViewModel I have...

How to implement menuitems that depend on current selection in WPF MVVM explorer-like application

I am new to WPF and MVVM, and I am working on an application utilizing both. The application is similar to windows explorer, so consider an app with a main window with menu (ShellViewModel), a tree control (TreeViewModel), and a list control (ListViewModel). I want to implement menu items such as Edit -> Delete, which deletes the curre...

Automapper use in a MVVM application

I am building a MVVM application. The model / entity (I am using NHibernate) is already done, and I am thinking of using AutoMapper to map between the ViewModel and Model. However this clause scares the jebus out of me: (from http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx) Bl...

ASP.NET MVC ViewModel Auto Generation

Hi there, I have a load of ADO.NET Entities in my MVC project. I was going to use these entities directly from my views/controllers... however, I think it's probably best to use ViewModels which more accurately reflect what the View requires. I'm looking for a way that I can auto-generate a ViewModel from an existing Entity, i.e., auto...

Setting WPF commands from multiple view models

Like any MVVM WPF app I have a handful of view models. Each has a few commands. My view implements a Fluent UI (Office ribbon) so there are some items that light up based on the context of the application. The ribbon is a child to the main application. The basic structure of my app is that it manages a COURSE. A COURSE has multiple MODU...

Trouble binding command to button in WPF

I've got a button in a ribbon I've implemented and having trouble binding to a command. The ribbon is in a UserControl named AppRibbon. The AppRibon control has a public property called SelectedModule which has a property named RenameModuleCmd. When I create an event handler for the button, i call the command explicitly to make sure ever...

WPF List of ViewModels bound to list of Model objects.

In the model, I have: public ObservableCollection<Item> Items { get; private set; } In the ViewModel, I have a corresponding list of ItemViewModels. I would like this list to be two-way bound to the model's list: public ObservableCollection<ItemViewModel> ItemViewModels ... In the XAML, I will bind (in this case a TreeView) to the...