viewmodel

Populate List<Objects> From Mvc 3 view

99封情书 提交于 2019-12-10 21:26:54
问题 I Have a Viewmodel based on Nominees . And i can have Multiple Nominees for the viewmodel. I want to populate the Ilist From the view . Here are my viewmodels public class DebitViewModel:IValidatableObject { public string AgentName { get; set; } public Debit Debit { get; set; } public Policy Policy { get; set; } public PolicyType PolicyType { get; set; } public Customer Customer { get; set; } public IList<PolicyType> PolicyTypes { get; set; } public List<Nominee> Nominees { get; set; } public

MVVM - calling UI-logic in code behind from ViewModel

*爱你&永不变心* 提交于 2019-12-10 20:02:22
问题 I'm working on some .Net XAML application using MVVM pattern. According to MVVM I keep my app logic in VM and in Code Behind I do UI-related actions. But I need to execute some UI-related code in Code Behind in respond to some logic in VM. Example: I need to show an error message (custom toast notification in my case) when login operation failed. Login operation resides in VM, but I can't use any UI-specific classes in my VM, so I made an event in VM and hooking up to in in Code Behind, doing

Android: how to add items and refresh list when using PagedList?

南楼画角 提交于 2019-12-10 18:56:11
问题 I've used PagedList for loading page of items and display them in RecyclerView, and it is successfully displaying list of numbers(0,1,2,3....,99), the list can always be scroll up and down without any problem. When I tried to click a button to call appendItems() to append new data, its still fine. However, the app crashed when I scroll the list. java.util.ConcurrentModificationException at java.util.AbstractList$SubAbstractList.size(AbstractList.java:360) at androidx.paging.PagedStorage.get

Should ViewModels be used in every single View using MVC?

心不动则不痛 提交于 2019-12-10 15:53:37
问题 I understand you use a ViewModel to store different data from other Models and sources to be used in a View, as a Model will not always hold what you want. I'm trying to figure out if it is proper to use a ViewModel for every single View. The reason I am asking is for consistency reasons. You could have a View that only needs the Model itself and another View that has to have a ViewModel. Is it good to mix these up between all your Views? Or should every View have a ViewModel? This is

Binding the displayed pattern (Path) to data model/How to make paths the same dimensions

笑着哭i 提交于 2019-12-10 15:46:05
问题 Background [Feel free to skip this] I'm building a program that deals with horses, their owners, and the owner's racing colours (silks). This question is about a UserControl , called SilksControl that acts as a view for the JockeySilks . To represent the silks I use the following class of enums: public class JockeySilks { public BodyPatterns BodyPattern { get; set; } public Colour BodyColour1 { get; set; } public Colour BodyColour2 { get; set; } public SleevePatterns SleevePattern { get; set;

Is it a good idea to aggregate ViewModels?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 15:15:17
问题 Is it a good or bad idea to have a ViewModel as a property of another ViewModel? For example: public sealed class ContentManagerViewModel : ViewModel { public FindViewModel Find { get; set; } } 回答1: It's good, if it helps. But it all depends. Usually I do have aggregated viewmodels. E.g. I may have a main window viewmodel. It may consist of different parts. Each part may be a separate view model... If you could describe your particular architecture, we may give better advice :).. Cheers,

WPF/MVVM: Re-use a ViewModel in multiple Controller and Separation of Concerns

陌路散爱 提交于 2019-12-10 12:09:49
问题 In my AdministrationController I use a PupilViewModel like: _adminRepo.GetSchoolclassPupilList().ForEach(s => { SchoolclassViewModel sVM = new SchoolclassViewModel(s, _adminRepo); foreach (PupilViewModel pVM in sVM.PupilListViewModel) { pVM.Documents.DeleteDocumentDelegate += new Action<List<Document>>(OnDeleteDocument); pVM.Documents.AddDocumentDelegate += new Action(OnAddDocument); pVM.Documents.OpenDocumentDelegate += new Action<int, string>(OnOpenDocument); } SchoolclassList.Add(sVM); });

MVVM Creating the ViewModel

馋奶兔 提交于 2019-12-10 11:34:30
问题 Can somebody explain to me how exactly to create a ViewModel for the MVVM Pattern. I tried to understand the the tutorial here: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx , but I was unable to understand what exactly is happening in the code. Let's say we want to create a basic application about getting and adding people from and to a local database and displaying them in the View. How should the ViewModel look like and how to create the RelayCommands for it. First why do we set

MVC3 collection model binding with EditorFor

我的梦境 提交于 2019-12-10 10:57:49
问题 Regarding this post and this other one. Suppose I have the following: public class Foo { public string Value1 { get; set; } public string Value2 { get; set; } } public class BarViewModel { public string Baz { get; set; } public IList<Foo> Foos { get; set; } } And I have a view that receive a BarViewModel : @model BarViewModel @Html.EditorFor(model => model.Baz) <table> @for(int i = 0 ; i < Model.Foos.Count ; i ++) { string name1 = "Foos[" + i.ToString() + "].Value1"; string name2 = "Foos[" +

Register viewmodel in different project from main project viewmodellocatoe in mvvmlight

混江龙づ霸主 提交于 2019-12-10 10:21:34
问题 How do I register a viewmodel in a different referenced project in the ViewModelLocator class of MVVMLight. I keep getting an error when ever I try to use the SimpleIoc to register the viewmodel class because it's in a different project, and I'd Like to keep different projects for different parts of my application. 来源: https://stackoverflow.com/questions/14898301/register-viewmodel-in-different-project-from-main-project-viewmodellocatoe-in-mv