Tag: mvvmcross

如何更新子视图模型时如何更新父视图模型

在我的第一个视图模型(重命名为MainViewModel)中,我有一个ActionViewModel列表。 在我的xaml中,我有一个绑定到列表的列表框,在列表框中我有一个模板,它绑定到ActionViewModel的属性。 到目前为止一切都很好,一切正常。 选择其中一个列表项时,我会导航到ActionViewModel并使用它传递id。 ActionViewModel从内存中的静态列表中检索信息,MainViewModel还从中检索信息以创建actionviewmodel列表。 到目前为止仍然很好,我可以编辑属性,所有绑定工作正常,我很高兴。 通过单击保存按钮,信息将被收集并存储在静态列表中。 当我点击后退按钮时,我会返回列表,但遗憾的是显示的值仍然相同,是否有某种方法可以发送命令重新加载列表中的项目? 传递一个完整的viewmodel作为对新ActionViewModel的引用? 或者某些属性告诉父母’你的列表中的这个视图模型已被更新’? 我确信上面的文字有点令人困惑,所以这里有一些代码来澄清它(希望如此) MainViewModel.cs private List _actionViewModels; public List ActionViewModels { get { return _actionViewModels; } set { _actionViewModels = value; RaisePropertyChanged(() => ActionViewModels); } } private Cirrious.MvvmCross.ViewModels.MvxCommand _navigateToAction; public System.Windows.Input.ICommand NavigateToAction { get { _navigateToAction = _navigateToAction ?? new Cirrious.MvvmCross.ViewModels.MvxCommand((action) => NavigateToTheDesiredAction(action)); return _navigateToAction; } } […]

在MVVMCross中将对象传递给“导航到”viewmodel的最佳方法是什么?

我有一个ViewModel,它包含一个Team,它有一个Players属性,它是一个Player对象列表。 在TeamView中,Team是深度加载的,因此播放器数据已经在内存中。 将给定的选定Player类实例传递给PlayerView的最佳方法是什么? 问题是MVVMCross ViewModel构造函数只能包含当前版本的字符串属性。 我有以下想法: 传递所选Player的Id并将Team.Players属性作为ViewModel分配给PlayerView。 如果所选择的玩家只是PlayerView中的焦点玩家并且PlayerView实际上是“玩家”视图,那么这可以是合理的解决方案,其中用户也可以在其他团队玩家之间滑动。 有一个像ViewBag一样的ASP.Net MVC服务,它只能在导航动作之间传递数据,在类似存储的字典中,传递给PlayerView的参数是一个“viewbag:PlayerId123”,它是一个指向类实例的特殊键。 将所选对象序列化为字符串,并将其作为序列化对象传递给构造函数。 这是有可能的,但我不喜欢这个解决方案。

MvvmCross – 从View模型调用Web服务

我是MvvmCross和Android开发的新手。 我需要在视图模型中调用POST数据到JSON Web服务。 然后,我需要在我的UI中显示Web服务的结果。 我的视图模型的要点如下所示: public class MyViewModel : MvxViewModel { public override void Start() { base.Start(); } public event EventHandler Service_Finished; public void CallService() { string url = GetServiceUrl(); WebRequest serviceRequest = HttpWebRequest.Create(url); serviceRequest.Method = “POST”; serviceRequest.ContentType = “application/json”; serviceRequest.BeginGetRequestStream(new AsyncCallback(ServiceBeginGetRequestStreamCallback), serviceRequest); } private void ServiceBeginGetRequestStreamCallback(IAsyncResult ar) { string json = GetJson(); HttpWebRequest myWebRequest […]

处理不同MvvmCross(v3)平台的GoBack的最佳方法是什么

在MvvmCross v3中,我使用ShowViewModel导航到不同的页面。 在转换为Mvx之前,我使用NavigationService.GoBack()方法返回上一页。 优点是不重新创建页面。 由于GoBack方法是特定于WP,WInRT,Silverlight的平台,处理返回上一页的最佳方法是什么,因此视图模型保持独立于平台? 一种解决方案可能是使用ShowViewModel传递视图可以看到的一些数据,然后在WP / WinRT的情况下,从视图中调用RemoveBackEntry 。 但是对于Mvx,可能有更好的方法。

MvvmCross Monotouch – 无法在真实的iPad上绑定属性,但它可以在模拟器上运行

我正在与MvvmCross Monotouch合作。 以下是在iOS模拟器上实际运行良好的绑定代码。 { this, “{‘Title’:{‘Path’:’NavigationBarTitle’}} 但是,当我在真正的iPad(iPad 2)上部署它时,它不起作用。 Application Output: =================== MvxBind: Warning: 0.69 Failed to create target binding for from NavigationBarTitle to Title 我很高兴看到它可以在iOS模拟器上运行但是,有什么理由说它不能在真正的iPad上运行吗? 帕特里克

MvvmCross – MvxListView绑定多次点击

我正在使用MvvmCross开发一个应用程序,我在Android应用程序中遇到问题,设置绑定以捕获构成MvxListView项目的两个不同控件中的单击操作。 ViewModel中所有数据的绑定都可以正常工作这是我的FavouritesView的AXML 而MvxItemTemplate在这里: 这是我的FavouritesViewModel: using System; using Cirrious.MvvmCross.Plugins.Messenger; using MyApp.Core.Managers; using MyApp.Core.Services; using System.Collections; using MyApp.Core.Domain; using System.Collections.Generic; using Cirrious.MvvmCross.ViewModels; using System.Collections.ObjectModel; using System.ServiceModel.Channels; using Cirrious.CrossCore; using MyApp.Core.Messages; using MyApp.Core.Helpers; namespace MyApp.Core.ViewModels { public class FavouritesViewModel: StandardsViewModel { private IFavouritesService _favouritesService; public FavouritesViewModel (ITextService textService, IMvxMessenger messenger, ISettingsManager settingsManager, IPageService pageService, IFavouritesService favouriteService): base(textService, messenger, […]

在IOS上使用mvvmcross绑定的问题(在模拟器上工作,但某些属性在设备上不起作用)

问题在于绑定到UIBarButtonItem,代码在Simulator上工作,但在设备上属性Enable不起作用,Clicked Works … textViewItem中存在同样的问题,但这次text或enable都不起作用。 public partial class ProcessDetailViewController : MvxBindingTouchViewController { public ProcessDetailViewController (MvxShowViewModelRequest request) : base (request,”ProcessDetailViewController”, null) { } public override void DidReceiveMemoryWarning () { // Releases the view if it doesn’t have a superview. base.DidReceiveMemoryWarning (); // Release any cached data, images, etc that aren’t in use. } public override void ViewDidLoad […]

如何在Mvvmcross中使用CanExecute

我有一个按钮 我有一个命令 public IMvxCommand DisconnectCommand { get { return new MvxRelayCommand(this.GetService().Disconnect); } } 然后我想使用启用/禁用DisconnectCommand DisconnectCommand.CanExecute(this.GetService().UsbConnected); 但这显然是错误的(它不起作用),我把检查作为一个参数,但通常我会这样做 DisconnectCommand.CanExecute = someBool; 但是没有设置属性,那么如何解决这个问题呢?

如果我知道资源的名称,则返回资源的id

如果我知道资源的名称,我怎么能返回资源的id? 像这样的东西: String mDrawableName = “myappicon”; int resID = getResources().getIdentifier(mDrawableName , “drawable”, getPackageName());

在MVVMCross上从ViewModel执行UI代码

我刚开始使用MvvmCross,但我没有找到任何关于如何从ViewModel执行UI代码的信息。 在Caliburn上有coroutine,所以我可以访问视图并保持ui代码与viewmodel代码分开。 在我的第一个案例中,我需要从ViewModel中的命令打开一个拨号,这是正确的方法吗? 现在我正在开发一个WinRT应用程序。 谢谢