Вопрос по c#, windows-phone-7 – Каков наилучший способ передачи объектов в view-модель «переход к» в MVVMCross?


Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Pass the Id of the selected Player and assign the Team.Players property as a ViewModel to the PlayerView. This can be a reasonable solution if the selected player is just the focused player in the PlayerView and the PlayerView is really a "players" view, where the user can swipe between the other team players as well.

Have a ASP.Net MVC like ViewBag service which can carry data only between navigate actions, in a Dictionary like storage, and the parameter passed to PlayerView is a "viewbag:PlayerId123" which is a special key pointing to the class instance.

Serialize the selected object to string and pass it as serialized object to the constructor. It is possible but I don't like this solution.

Ваш Ответ

1   ответ

that the TeamViewModel gets the team data from the network using an injected ITeamService that the TeamViewModel also uses an injected singleton ITeamCache to cache the Team that the navigation happens via a call like:

this.RequestNavigate<PlayerViewModel>(new { teamId, playerId })

the PlayerViewModel then receives the TeamId and PlayerId in its constructor, and uses the ITeamCache to collect the right player

 public class TeamViewModel 
     : MvxViewModel
     , IMvxServiceConsumer<ITeamCache>
     public TeamViewModel(string teamId, string playerId)
         var teamCache = this.GetService<ITeamCache>();
         Player = teamCache.GetPlayer(teamId, playerId);
         if (Player == null)
             // todo - handle this error somehow!

     public Player Player { get; set; }


Android lifecycle from Xamarin docs enter image description here

Implementing the ITeamCache as a file-backed object - e.g. it could use a JSON file or a SQLite database as a persistent store for the in-memory data Implementing some logic in your code that refetches data from the network when needed Implementing some emergency-navigate-back-home strategy in these cases - as these cases don't happen that often in many applications on modern resource rich phones. Just crashing - although this isn't advisable...

Error: User Rate Limit Exceededslodge.blogspot.co.uk/2013/01/…
Error: User Rate Limit Exceededgithub.com/slodge/MvvmCrossConference
Error: User Rate Limit Exceeded Attila Hajdrik
Error: User Rate Limit Exceeded

Похожие вопросы