viewmodel

Android ViewModel call Activity methods

我们两清 提交于 2019-12-04 02:18:40
I'm using android AAC library and Android databinding library in my project. I have AuthActivity and AuthViewModel extends android's ViewModel class. In some cases i need to ask for Activity to call some methods for ViewModel. For example when user click on Google Auth or Facebook Auth button, which initialized in Activity class (because to initialize GoogleApiClient i need Activity context which i can not pass to ViewModel, view model can not store Activity fields). All logic with Google Api and Facebook API implemented in Activity class: //google api initialization googleApiClient = new

MvvmCross ViewModel caching and re-initializing

老子叫甜甜 提交于 2019-12-04 01:30:27
问题 I need to be able to intercept the framework and perform so re-initialization when a ViewModel is being reloaded from the cache. Since the ViewModel is not being recreated, I can neither use the Init(), MvxViewModel.InitFromBundle, nor MvxViewModel.ReloadFromBundle methods. I am trying to debug a situation where clicking on the back button restores a ViewModel with inconsistent state. Some sort of MvxViewModel.OnReloading() would help. Is there a way to do this in v3? EDIT: Assume I have

When is it right to use ViewData instead of ViewModels?

三世轮回 提交于 2019-12-04 00:38:00
问题 Assuming you wanted to develop your Controllers so that you use a ViewModel to contain data for the Views you render, should all data be contained within the ViewModel? What conditions would it be ok to bypass the ViewModel? The reason I ask is I'm in a position where some of the code is using ViewData and some is using the ViewModel. I want to distribute a set of guidelines in the team on when it's right to use the ViewData, and when it's just taking shortcuts. I would like opinions from

MVC3 - Insert using ViewModel - Object reference not set to an instance of an object

做~自己de王妃 提交于 2019-12-03 23:43:39
I have got two models, seen below, and am trying to insert one of each to the database from one view. I have created a view model in an attempt to do this. public class Blog { public int BlogID { get; set; } public string Title { get; set; } public DateTime CreatedOn { get; set; } public virtual User User { get; set; } public virtual ICollection<BlogPost> Posts { get; set; } } public class BlogPost { public int PostID { get; set; } public string Body { get; set; } public DateTime CreatedOn { get; set; } public int UserID { get; set; } public virtual User User { get; set; } } public class

Android Architecture Components: How is LiveData in the repository observed by a ViewModel

ぃ、小莉子 提交于 2019-12-03 23:11:48
问题 i'm studying the Android Architecture Components and i'm a little bit confused. In the sample they use a repository and state that changes within the datasource of the repository are observed by the ViewModels. I don't understand how the changes within the datasource are pushed to the ViewModels, as i cannot see any code within the ViewModels that subscribes them to the repository. Analogously, the fragments observe the ViewModel's LiveData, but they actually subscribe to the LiveData: //

name 'html' nor name 'model' exist in current context in usercontrol MVC and C#

非 Y 不嫁゛ 提交于 2019-12-03 21:48:09
I am using Microsoft MVC and C#. I have a usercontrol (example.ascx) created and at the top I'm inheriting System.Web.MVC.ViewUserControl<PostTransferViewModel> Now, while my model name is appended to ViewUserControl, I get "The name 'Model' does not exist in the current context" and "The name 'Html' does not exist in the current context. If I removed the <PostTransferViewModel> from the end of ViewUserControl then everything works fine, but I need <PostTransferViewModel> . <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PostTransferViewModel>" %> <div class=

convert model to viewmodel [duplicate]

谁说我不能喝 提交于 2019-12-03 21:24:12
This question already has answers here : Closed last year . Where to convert business model to view model? (3 answers) I have a table name "Product" and another table name "category". Product table has 'productID', 'productName' and 'CategoryID'. Category table has 'categoryID' and 'categoryName'. My target is to display a list of products with category. The list will contain 'product id', 'product name' and 'category name'. I have created a viewmodel. the code is public int prodID{get;set;} public int prodName{get;set;} public int catName{get;set;} In my controller, I have: var query= from p

Binding collections in MVC

浪子不回头ぞ 提交于 2019-12-03 21:10:18
问题 I have a View Model that consists of an Applicant object and a TeamMember collection. When I post the model back the Team collection is always null. I've tried changing the collection from my original IEnumarable to a List but that didn't make a difference. So I changed the Controllers Edit Action to accept the FormCollection , and verified there was data in viewModel["member.FirstName"] . I'm lost as to why the binding isn't working. I tried to clean out my code samples as much as possible

How to pass data (selected item) to Durandal composed detail view?

為{幸葍}努か 提交于 2019-12-03 17:45:45
问题 I've started using (as of, a few hours ago) Durandal with the hope to manage views and allow composition within a single page - the previous approach, also using Knockout, was getting too unwieldy to maintain in a fat HTML file. I've installed/setup Durandal and I can create views and viewmodels - however, I don't know how to get data into the viewmodel to use as a basis for the new viewmodel. For instance, I have a "left nav bar" for selecting items - when an item is selected it updates a

Kotlin dagger 2 Android ViewModel injection error

拥有回忆 提交于 2019-12-03 17:09:30
I'm trying to use dagger 2 on my Android application to inject the new ViewModel from arch android library. From what I see on this sample https://github.com/googlesamples/android-architecture-components/tree/e33782ba54ebe87f7e21e03542230695bc893818/GithubBrowserSample I need to use this: @MustBeDocumented @Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @Retention(AnnotationRetention.RUNTIME) @MapKey internal annotation class ViewModelKey(val value: KClass<out ViewModel>) @Module abstract class ViewModelModule