viewmodel

Making a javascript knockout viewmodel without the new keyword

╄→гoц情女王★ 提交于 2020-01-01 18:30:15
问题 I'm looking through the knockout tutorials, and all the examples create the view model using the 'new' keyword: //from learn.knockoutjs.com function AppViewModel() { this.firstName = ko.observable("Bert"); this.lastName = ko.observable("Bertington"); this.fullName = ko.computed(function() { return this.firstName() + " " + this.lastName(); }, this); } ko.applyBindings(new AppViewModel()); I'm trying to avoid using the new keyword, which usually works perfectly ok, but I find trouble getting

Generic View Models?

我的未来我决定 提交于 2020-01-01 05:46:07
问题 I am wondering is it good practice to try to make a view that takes in a generic view model? I am wondering this because someone mentioned that he was anticipating to have to do lots of duplicate code unless he started to make a generic view and generic view model. So basically the views would be like just a set of controls. One view might have 2 controls(say a text-box and radio button) another view might have 50 controls on it. They will all have the same look and feel(it just grows by

ASP.NET MVC 2 - ViewModel Prefix

走远了吗. 提交于 2020-01-01 04:37:32
问题 I want to use RenderPartial twice in my view with different models associated. The problem is that some properties are present in both models (nickname, password). They have no prefix, so even the id's or names are equal in the output. Now, if I have model errors for nickname or password, both fields get highlighted. Main View: <div> <% Html.RenderPartial("Register", Model.RegisterModel); %> </div> <div> <% Html.RenderPartial("Login", Model.LoginModel); %> </div> Login PartialView: <% using

ASP.NET MVC 2 - ViewModel Prefix

萝らか妹 提交于 2020-01-01 04:37:28
问题 I want to use RenderPartial twice in my view with different models associated. The problem is that some properties are present in both models (nickname, password). They have no prefix, so even the id's or names are equal in the output. Now, if I have model errors for nickname or password, both fields get highlighted. Main View: <div> <% Html.RenderPartial("Register", Model.RegisterModel); %> </div> <div> <% Html.RenderPartial("Login", Model.LoginModel); %> </div> Login PartialView: <% using

Should I map a domain object to a view model using an optional constructor?

戏子无情 提交于 2020-01-01 03:16:09
问题 I'd like to be able to map a domain model to a view model by newing up a view model and passing in the contributing domain model as a parameter (like the code below). My motivation is to keep from re-using mapping code AND to provide a simple way to map (not using automapper yet). A friend says the view model should not know anything about the "payment" domain model that's being passed into the optional constructor. What do you think? public class LineItemsViewModel { public

Binding SelectionChanged to ViewModel using Caliburn.Micro

回眸只為那壹抹淺笑 提交于 2019-12-31 20:18:28
问题 We've using Caliburn.Micro on a new Silverlight project and everythings working great. The inbuilt conventions bind buttons click events to the viewModel, but I'm not sure what the best way to handle the selectionChanged event on datagrids and comboboxes is. At the moment, I'm binding to the selected item and calling custom logic, but I feel like this is a bit of a code smell and that I should seperate the setting of the property and the selectedChange event. But if I seperate these, how do I

Binding SelectionChanged to ViewModel using Caliburn.Micro

有些话、适合烂在心里 提交于 2019-12-31 20:18:11
问题 We've using Caliburn.Micro on a new Silverlight project and everythings working great. The inbuilt conventions bind buttons click events to the viewModel, but I'm not sure what the best way to handle the selectionChanged event on datagrids and comboboxes is. At the moment, I'm binding to the selected item and calling custom logic, but I feel like this is a bit of a code smell and that I should seperate the setting of the property and the selectedChange event. But if I seperate these, how do I

Model does not apply DataType.Password

懵懂的女人 提交于 2019-12-30 17:19:12
问题 Instead of using the object directly, on a simple Razor View I have a form using as it+s model a decorator object. public class GlobalAccount { public GlobalAccount() { this.TestService = new TestServiceModel(); } public TestServiceModel TestService { get; set; } } beeing TestServiceModel represented as public class TestServiceModel { [Required] [Display(Name = "Endpoint (url of your service like http://mydomain/remote/)")] public string Endpoint { get; set; } [Required] [Display(Name =

Two views - one ViewModel

半世苍凉 提交于 2019-12-30 12:57:23
问题 I must have misunderstood the concept of ViewModels and Views. But at this moment I can't rebuild the application from ground and this time doing it better. My situation is that I have a view where the user can load files and read them, a plotter shows the graphs and some operations are implemented. I want to be able to generate reports (like summary) of the data but I want it in other view. I'm using ModernUI, this other view is in another tab. What I want is have that two tabs synchronized,

How can I avoid command clutter in the ViewModel?

ぐ巨炮叔叔 提交于 2019-12-30 06:20:10
问题 I am building an application that uses quite a few commands, and they are cluttering up my viewmodel. MVVM is new to me, so sorry if this question is a bit stupid. Is there a way to reduce the clutter? For example here you can see the a part of the clutter.. private void InitializeCommands() { LogoutCommand = new RelayCommand(Logout); OpenCommand = new RelayCommand(SetImage); SaveCommand = new RelayCommand(SaveImage, SaveImageCanExecute); UploadToFlickrCommand = new RelayCommand