viewmodel

How to validate ViewModels derived from an abstract class?

孤街浪徒 提交于 2019-12-11 19:45:40
问题 I have the following EditorTemplate @model ESG.Web.Models.FileInfo // <-- Changed to BaseFileInfo @{ ViewBag.Title = "FileInfoEditorTemplate"; } <fieldset> <table class="fileInfoEdit"> <tr> <td>Base Directory:</td> <td>@Html.EditorFor(model => model.Directory)</td> <td>@Html.ValidationMessageFor(model => model.Directory)</td> </tr> <tr> <td>Filename:</td> <td>@Html.EditorFor(model => model.Filename)</td> <td>@Html.ValidationMessageFor(model => model.Filename)</td> </tr> </table> </fieldset>

Room not returning duplicates

北战南征 提交于 2019-12-11 19:35:35
问题 So I have a room database all set up, everything is fine, so I can make queries and inserts, delete etc no problems, however i've just run into a situation where id like to return entries by their Ids and duplicates should be allowed, however room is removing the duplicates, so for instance I send it a list of ids say <1,2,3,2,3> and it returns items by their ids but only sends me <1,2,3> removing the duplicate entries. The query I'm making is below (btw complete noob at sql) @Query("SELECT *

Retrieve Data From multiple tables in MVC ASP.NET

时间秒杀一切 提交于 2019-12-11 18:33:17
问题 I have a ViewModel which I have made using my base Models. I am also able to insert data into the tables. I want to now retrieve the data and show on my form. What code should I write in my Index View . My ViewModel is composed of properties from 2 different base models .Hence, in the view , when i try to get information using properties from my ViewModel , it gives the "Object not set to an instance of an object" Error. Codes are as Follows : ViewModel Class : public class

Populate a drop down list with view model property: MVC 5, Razor

耗尽温柔 提交于 2019-12-11 15:50:03
问题 I've got a view with a few properties and want to create a drop down box for it. So far, I've created a list of selectListItems on my controller and added values to it and at the moment, it works and displays the items in the drop down list. However, my problem is that it's not linked at all to the property I have in my view model. How can I amend this? controller: List<SelectListItem> jobs = new List<SelectListItem>(); SelectListItem job1 = new SelectListItem() { Text = "Email", Value = "1",

Xamarin View with ViewModel and Behaviour

风格不统一 提交于 2019-12-11 15:45:35
问题 I have a View which contains the userprofile of the current user. The view contains a viewmodel with a two-way binding to the single attributes like username or email adress. The view also has a behaviour, which validates the input and shows an error, of the input is not valid. Because of the two-way binding, the viewmodel updates the value even if the behavior says the input is wrong. I need to solve that. My current approach is to use include the behavior in the viewmodel as a attribute. So

ASP.NET MVC Viewmodel returns nothing

蓝咒 提交于 2019-12-11 15:21:44
问题 Trying to make a simple application but my view returns nothing when trying to use a viewmodel. I assume the "db.[TableName].ToList();", which works when applied on a domain model, is not enough and the selection should happen in a different way when using a viewmodel, but I have no idea how to do it. Please help. Thank you. Town.cs using System.Collections.Generic; namespace City.Models { public class Town { public Town() { Streets = new List<Street>(); } public int TownId { get; set; }

MVVM Cross - passing parameters

一笑奈何 提交于 2019-12-11 15:05:57
问题 I'm trying to pass objects across view models in MVVM Cross. Here's the code for the VM that I'm passing from: private void CallVM2() { MyObj newObj = new Myobj(); IMyService myService = new MyService(); Dictionary<string, object> p = new Dictionary<string, object>() { {"MyObj", newObj}, {"MyService", myService} }; ShowViewModel<ViewModel2>(p); } And here's the code for ViewModel2: public void Init(Dictionary<string, object> p) { } Okay - so I tried InitFromBundle too, but it appears that I

Updating dependent property once instead of twice

元气小坏坏 提交于 2019-12-11 14:11:22
问题 In my ViewModel I have two properties type of Datetime. They are bound in XAML with TwoWay mode. When I update each of them - OnPropertyChanged raises in set part of this Datetime property for the third property. So I want to update the third property only once when I update two Datetime properties at the same time, instead of updating third property twice. How it can be archieved? Code applied: //1 public DateTime StartDate { ... set { this.selectedEndDate = value; this.OnPropertyChanged(

MVVM - Binding Expression errors when createing a View in XAML with a ViewModel DataTemplate

て烟熏妆下的殇ゞ 提交于 2019-12-11 12:39:43
问题 This is a WPF application. Background: I essentially have a Wizard application. The Wizard is initialized by providing a list of ViewModels. These ViewModels will create the appropriate view based on some DataTemplate in my XAML. When clicking next or previous in the Wizard, the appropriate ViewModel will be set and the view will be loaded based on the DataTemplate. This works fine. Problem: When I'm in a transitory state...meaning the new viewModel is being loaded, it appears there is a

Can't get selected drop down value to bind to view model property

冷暖自知 提交于 2019-12-11 10:27:27
问题 I'm having trouble binding the selected value of a drop down list to the correct property in my view model. I can't see what I am doing wrong here. I've put the code that should help show what I'm doing below. I've omitted some things such as the population of the 'AllFolders' property of the view model, as it's just a simple List with an object called ImageGalleryFolder . Every time the form posts back, the ParentFolderId property is null without fail. This is driving me crazy and I've