viewmodel

Binding data to child Listview element in xamarin

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 15:45:09
问题 I am trying to create a List view control in Xamarin Forms. The list view contains another listview in its datatemplate. Data is getting binded from the viewmodel. But on first go the inner list view is not showing any data. But will show data if tried to scroll the list. <ListView ItemSource="{Binding ParentSource}"> <ListView.ItemTemplate > <DataTemplate> <ViewCell> <ViewCell.ContextActions> <MenuItem Text="Delete" /> </ViewCell.ContextActions> <ViewCell.View> <Label Text="{Binding Prop1}"/

ViewModel Event Registration and ViewModel Lifetime

♀尐吖头ヾ 提交于 2019-12-24 13:40:29
问题 I have an architectural problem, and a possible solution for which I would like an opinion. I'm used to MVVM architecture for WP7 (whenever possible but unfortunately sometimes the sdk seems to go on the opposite direction). WP7 force an ViewFirst approach and I feel confortable with this (except for the part that we can't override the View creation, as in Silverlight, to made constructor injection possible). I found myself confident by having most of the viewmodel follow the lyfetime of its

MVVM: How to pass ObservableCollection to other viewmodels?

烂漫一生 提交于 2019-12-24 12:26:56
问题 I'm designing an MVVM framework and I need to know if my understanding of MVVM pattern is correct or not. My question is simple. How should I pass the ObservableCollection object between the VieModels? or shouldn't I? I have a CustomerViewModel which has an ObservableCollection to hold a list of customers. I also have an InsertCustomerViewModel which is responsible for insertng new customer models in to that ObservableCollection. in the InsertCustomerViewModel I have a method called Insert()

what is the best way to bind ViewModel data to master page in asp.net-mvc

安稳与你 提交于 2019-12-24 10:39:26
问题 I want to dynamically create my menu on my master page and i have seen 2 different approaches: First approach is have a base controller that loads up all shared view model data in its constructor. This is described here Second approach is to create a separate controller for this and use this in your master page to inject specific view pieces into the master page without polluting your regular page view generation: @Html.Action("Index", "Settings") Is one better than the other? Is there any

DisplayFor is not keeping data in ViewModel on PostBack

两盒软妹~` 提交于 2019-12-24 09:21:47
问题 This question has been asked before by other, but still don't get it. I am using MVC3 Razor and I have screen for entering trouble tickets. Once data (a textarea note) is entered, the controller redirects back to the same screen. Most of the data is for display only. If I use DisplayFor or DisplayTextFor, the data is not being posted back. I have used HiddenFor. That works. However, I keep hearing from others that HiddenFor is not ideal. I don't want to editorfor because, I want to easily

when to use the poco objects for views, and when the custom viewmodel classes

≯℡__Kan透↙ 提交于 2019-12-24 08:25:06
问题 Imagine that we have a poco that maps a table in a db. There are 15 fields in a poco, only 3 fields of 15 require the view. View display a list of records from db. Can I pass to the view list of poco's objects or I must to create a specific viewmodel class, init it and then pass to the view? I prefer the second variant, but is it good? Thanks. 回答1: Your inclination to the second approach is well founded. Creating and using viewmodels is the typical way for displaying data on View. In short,

Android Architecture Components LiveData

大城市里の小女人 提交于 2019-12-24 06:08:46
问题 I'm trying to implement a simple App using Architecture Components. I can get the info from RestApi services using Retrofit2. I can show the info in the respective Recyclerview and when I rotate the phone everything works as it should. Now I want to filter by a new kind of object (by string) Can someone guide me a little with the ViewModel, I don't know what is the best practice to do that... I'm using MVVM... This is my ViewModel: public class ListItemViewModel extends ViewModel { private

Not able to import InstantTaskExecutorRule in my 'jUnit' test case even after adding 'core-testing' dependency - Android testing

纵然是瞬间 提交于 2019-12-24 03:42:53
问题 I am writing test cases for my LoginViewModel . Where I want to perform setValue() operation on my MutableLiveData . To avoid Method getMainLooper in android.os.Looper not mocked Exception I am trying to add the following Rule in my ViewModel file inside test folder . @Rule public InstantTaskExecutorRule mInstantTaskExecutorRule = new InstantTaskExecutorRule(); for that, I have added the following dependency: androidTestImplementation 'android.arch.core:core-testing:1.1.1' as dependency. But

The model item passed into the dictionary is of type A, but this dictionary requires a model item of type B

妖精的绣舞 提交于 2019-12-24 03:19:13
问题 Ok, there are a ton of questions like this and I've looked through about 1500lbs of it. The ones that I saw, people were either sending the wrong type or they were doing something with a partial view. I am doing neither in my case. So, my exact error is: The model item passed into the dictionary is of type 'ClanSite.Models.ViewModels.CategoryViewModel', but this dictionary requires a model item of type 'ClanSite.Models.ViewModels.UserLoginViewModel'. The issue is that I have a model on my

“EntityCollection already initialized” error with entity as model in Asp.Net MVC?

孤者浪人 提交于 2019-12-24 02:51:34
问题 I'm having great difficulties with creating a complex object. I have an EF model with a Consultant table that has one-to-many relationships to a number of other tables. I wanted to use the Consultant object as the model as is because it would be very simple and easy (and as it's done in the NerdDinner tutorial), as I've done with other objects that didn't have one-to-many relationships. The problem is that these relationships cause this error: "EntityCollection already initialized" when I try