viewmodel

How to capture PropertyChanged event from ViewModel?

I created two viewmodel, MyViewModel, MyViewModel2. MyViewModel2 include MyViewModel as property. MyViewModel include one entity MyEntity from EF/WCF Ria Service. In MyViewModel2, I want to capture any item changes in MyEntity for databinding. My code like below: public class MyViewModel : ViewModelBase { //.... public ...

Error with ViewModels and Create/Edit Actions

I'm trying to create a ASP.NET MVC 2 webapp using the Northwind database following the NerdDinner tutorial, but now I keep getting the following error when trying to EDIT a product: Value of member 'SupplierID' of an object of type 'Supplier' changed. A member defining the identity of the object cannot be changed. Consider adding...

ASP.NET MVC 2 View Model DDL lists: Where to store the choices, hard code in a view or store in a database?

We currently have a "Lookup" table which contains a set of possible choices for things like a drop down list. If this were a list of state abbreviations, LookupID would represent the set, and LookupItemID would represent the individual state. customerID int PK lookupID int PK lookupItemID int PK lookupValue string ...

How to hook ActiveX control into events/changes into my viewmodel?

Hi, I've added WindowsMediaPlayer ActiveX to my WPF/MVVM application. Now I need the control to react to changes happening in the viewmodel (most importantly updating URL when the current selection in my collection changes). Based on Walkthrough: Hosting an ActiveX Control in WPF I have the following in my Loaded event: // Create the i...

Ok to return a Viewmodel from repository?

Hello all, Been around here for a while but this is my first question @ so. Scenario: Mvc site. Viewmodels for most pages. Each viewmodel contains models or iqueryables acquired from different repositories. Each source is updated frequently (from outside the scoop of the site) so even if caching local it will be a lot of datasource h...

Understanding Forms in MVC: How can I populate the model from a List<>

Conclusion in Images, can be found in the bottom I'm having some trouble to get how Forms work in MVC (as I'm a WebForms Developer and really wanna start using MVC in one big project) I took the MVC2 Web Project and add a simple ViewModel to it namespace TestForms.Models { public class myFormViewModel { public myForm...

How to pass viewmodel to controller?

Hello, I've a problem with my viewmodel. I've a DropDownList with many translationvalues (pattern here) In My controller - HTTPGET : public ActionResult Edit(int id) { int DropDownListValueId = id; SelectListViewModel viewmodel = new SelectListViewModel(0, DropDownListValueId); return...

How can I use and populate a base view model in a master page?

I have an asp.net masterpage, and All my controllers inherit from a controller base. All my view models inherit from ViewBase. How can I have a base set of data in the master page that is populated from the base controller into the viewbase, then into the masterpage? ...

Is it a bad practice using model classes in controller in mvc?

Hi, I wanted to compare with best practices when working with an ORM or database tables in asp.net mvc. One of the major questions I have is should I instantiate the model classes directly in controller..not query the database but just use the model class to store the values. For e.g. If I am using entity framework as model...then is i...

Silverlight 4 Parent Child Info in dataGrid and RowDetailsTemplate

Hi All, I have three tables in my db, One Parent (Product) and two childs(ProductStyles, ProductSizes) which means that a Product can have multiple Styles and Sizes. Now What I want to do is:- 1) Shows the Products in dataGrid with having the columns Styles and Sizes and these columns should only display the Total Counts (ie how many st...

MVVM: One ViewModel structure for all Views vs. separate ViewModel structure per View?

Hi I'm new to MVVM and need a bit of help. My application consists of a number of different windows which display controls allowing the user to edit the data in the Business layer. At the moment, each time the user opens a new instance of one of these windows, a ViewModel structure - classes and collections mirroring the Business laye...

DefaultModelBinder not binding nested model

Looks like others have had this problem but I can't seem to find a solution. I have 2 Models: Person & BillingInfo: public class Person { public string Name { get; set;} public BillingInfo BillingInfo { get; set; } } public class BillingInfo { public string BillingName { get; set; } } And I'm trying to bind this straight into my ...

Communication between 6 ViewModels and a Messenger == AntiPattern ?

A common approach for communication between 2 ViewModels is this: http://stackoverflow.com/questions/2474768/mvvm-view-model-view-model-communications The Mediator pattern or a Messenger class. But what about 6 ViewModels in one Window? NewSchoolclassUserControl NewPupilUserControl SchoolclassListUserControl PupilListUserControl Pupi...

Dynamically checking each KeyValuePair value of a model

I have a view model like so that is created from my validator. public class ViewModel { public KeyValuePair<int, RuleType> Foo { get; set; } public KeyValuePair<string, RuleType> Bar { get; set; } } My real view model has 20+ field. Once my data is validated a generic list of type ViewModel is then returned to my MVC view and...

Make a Dialog ViewModel binding ready, call Dialog and return data from it in MVVM

Hello, Do you see a better way how I can call/contstruct a Dialog from a Controller/ViewModel return data from it and set the DocumentViewModel as DataContext of the Dialog? The problem is I can not use View first approach in the DocumentDetailWindow and its belonging UserControl because I can not set the Model to the DocumentViewModel...

Send an IOrder from ViewModel1 to ViewModel2 with a Messenger, how do you differentiate ADD/DEL ?

Hello, I have a CustomerListViewModel and a OrderListViewModel. In the latter I select an order to delete it or I create a new one. In both situations my CustomerListViewModel and the Messenger must register to the type IOrder: Messenger.Default.Register<IOrder>(this, AddOrder); Messenger.Default.Register<IOrder>(this, DeleteOrder); ...

Bind a SolidColorBrush to a DataGridCell/CellStyle from a ViewModel

Hello folks, I have a ViewModel with Property int DepartmentColor. Of course I can not bind the int value to a CellStyle in XAML. Should I make a IntToStyleConverter or should I fumble around with the Style class in the ViewModel like convert the int to a SolicColorBrush and assign it to a Style etc... Is the latter the way to go with...

ASP.NET MVC: using EF entities as viewmodels?

Possible Duplicate: ASP.NET MVC - Linq to Entities model as the ViewModel - is this good practice? Is is OK to use EF entities classes as view models in ASP.NET MVC? What if viewmodel is 90% the same of EF entity class? Let's say I have a Survey class in Entity Framework model. It 90% matches data required for view to edit i...

Bind model back when displayed with DisplayFor template

Hi I have the model public class PersonViewModel { public Guid Id { get; set; } public string Firstname { get; set; } public string Lastname { get; set; } } which is nested in an other view model: public class ApprovalModel { [UIHint("MyDisplayTemplate")] public PersonViewModel User { get; set; } [Required] ...

Order for ForEach on View Model

In MVC 2 I have a user control - Partial page as below. Model has four records id Dtext Dtext1 1 A, A1 2 B B1 3 C C1 4 D D1 On My machine - Output is as above in the ID Order which is expected. But after deployment output is totally bizarre something like below. D D1 B B1 A, A1 C C1 Would like to know ...