viewmodel

Would ViewModels fit in the Model View Presenter pattern?

Having used ViewModels in MVC, I was wondering if applying the same to the MVP pattern is practical. I only have a few considerations, one being that MVP is already fairly hard to implement (with all the additional coding, not much on the seeming complexity) or that ViewModels already have a slightly similar way of modeling data or entit...

asp.net mvc viewmodels. How much logic (if any) should they contain

Hi, I've been looking into view models for mvc and I'm looking for the best way to do them. I've read loads of different articles but none seem to be clear as the "best way." So far example I might have a Customer model with the following properties: First Name Last Name Title Location Where location is a foreign key to a location t...

How do I use DomainContext.Load to populate properties of my ViewModel?

I have a Silverlight page that gets its data from a view model class which aggregates some data from various (RIA services) domain services. Ideally I'd like the page to be able to data bind its controls to properties of the view model object, but because DomainContext.Load executes a query asynchronously, the data is not available when...

ASP.NET MVC ViewData and view model best practices

The initial situation is that I map my domain model into a presentation model. I have to display an update/create formular with textboxes and a dropdownlist. Should the viewmodel contain a list for the dropdownlist or should I pass the data for the dropdownlist by using ViewData? When schould I use ViewData and when don't I should use...

WPF: How do I have to setup my model and the binding strategy ?

Regard this image: The TimeTableViewModel of this user interface is this: public string SchoolclassCodeMonday {get;set;} public string SchoolclassCodeTuesday {get;set;} public string SchoolclassCodeWednesday {get;set;} public string SchoolclassCodeThursday {get;set;} public string SchoolclassCodeFriday {get;set;} public string Schoolc...

Complex data structure in ViewModel layer of the MVVM

I have large collection of MyFile objects which are linked in all kind of ways between each other like spaghetti. In addition, from this collection I create smaller subcollections of some items that are equal by some criteria. (for example all files with the extension .txt, all files that belong to certain directory etc...) Basically I ...

Bestpractice - Mixing View Model with Domain Model

Is it reasonable to mix view models with domain models? So i.e. the view model object contains some domain model objects (not the other way around!) ...

Create an instance of ISession per ViewModel

Hello all, here is my problem: I'm building a desktop application, with the following tools: Caliburn Ninject NHibernate All my view models and repositories are instanciated with Ninject. My repositories all need an ISession in their constructor. I'd like to follow ayende's advice concerning the ViewModels: each ViewModel opens a n...

Where to put "ViewModel Classes" in DDD approach?

Hi, As you may have seen the question from the title, i'm little bit confused about where to put the ViewModel classes in our web project. What is the best practice to putting ViewModel classes? Seperate assembly or in UI project? We're working on a project that is built upon Asp.net MVC2 with DDD approach. Thank you. ...

WPF MVVM call ViewModel Save method on Window Close

Hello, I have figured out how to close Window from my ViewModel. Now I need to solve window close problem from the other side. I need to trigger Save() method in my ViewModel when the user clicks window's close button. I was thinking about binding Command property to Window's close event, but my ViewModel is related to the user cont...

How to handle wpf datagrid MouseMove event in viewmodel...in MVVM pattern?

HI, I have a wpf-datagrid in view, i am following mvvm model...so no code in "codebehind". I wud like to handle "mousemove" event in viewmodel..how do i do this ? ...

I have a ViewModel strongly bound to my View in my ASP.NET MVC app, now what about the controller

So like the title says, I created a view model in my asp.net mvc application so it would be strongly typed to my view. My view model is a combination of two of my model classes. Now when the user hits the save button on that view, it goes to a controller. How does it know what controller to go to? I built my controller 1 - 1 so to sp...

ASP.NET MVC2, How to Add Metadata Attributes and Control the order of properties displayed in the View

In ASP.NET MVC2, I have two ViewModels with Parent-Child relationship as below. Parent ViewModel: public class PersonViewModel { [Required] public int ID{get;set;} [Required] [StringLength(50)] public string Name{get;set;} } Child ViewModel: public class EmployeeViewModel:PersonViewModel { [Required] [StringLength(50)] publ...

Replacing ViewModels with Tuples

Hey everyone, I've just started on a new project which currently contains a fair few ViewModel DTO classes. I'm wondering whether it would be useful and even good practice to replace many of these DTOs with Tuples and to use that as my method of transfering a bunch of objects to my views. What do you think? Is this a correct usage of ...

Problem when getting an entity which has been modified in another session

Hello all, I have a strange problem in my rich client application. Here is some background: I use one session per view model. My view models communicate with each others with a Mediator. I have a management view model where I display a list of my entities. I can edit an entity, which results in the opening of a new view model, whic...

Code generation for views broken when using custom MVC ViewData classes.

I'm by no means lazy, but already 2 days overdue on our current sprint in my first ever MVC project, so I've been using the Add View Wizard to generate strongly typed views, but now that I have started using ViewData classes as view models, the wizard generates fields for ViewDataBase, and not my derived ViewData. I think that the deriv...

Send Two Models into One View .Net in VB

Edit one more time: So it looks like I have figured out the address part too, in the class I have: Public ReadOnly Property addresses As IEnumerable(Of Address) Get Return _these_addresses End Get End Property And in the template I have: <% For Each item In Model.addresses%> <tr> ...

Question about ASP.NET MVC 2 Custom ViewModels

In my project I have my Linq To SQL dbml file, A Repository Layer for each DB Table and a Service Layer for each Repository. In my service I have some MetaData for Validation as well as I extend each (table) Class to add some custom information to the object (you'll see this in the code below). My question is, Should I consider buildin...

What are Best Practices for Property Declaration in a Custom ViewModel

In my new UserViewModel that I'm building for my application, I have two options for storing properties. The first option is to have Public Property user As User ''# Including the entire User object Public Property custString as String ''# Custom String for View The second option is to actually write out all the Use...

Drop down troubles in .net using VB and view model

OK I am new to .net, I am just taking a shot in the dark through this whole thing. I have an Addresses table with a StateID and CountryID field. They refer to the States and Countries table. I am using LINQ to SQL and Visual Studio 2010. In my AddressesController I have: Function Create() As ActionResult Dim these_states =...