2

我是一個MVVMCross的完整新手,但我試圖從github中獲取使用monodouch和Xamarin Studio與MVVMCross的最新二進制文件工作的依賴關係。國際奧委會不解決依賴關係 - MVVMCross

無法真正找到專用於Xamarin Studio + Monocross的教程,所以在配合一些教程後,我有一些微不足道的控件奇妙地工作。然後我嘗試着手繪製一些地圖特徵和一些DI。不幸的是,我收到錯誤,說依賴關係無法解決。我哪裏錯了?

// my view model 
using System; 
using Cirrious.MvvmCross.Plugins.Location; 
using Cirrious.MvvmCross.ViewModels; 
using Cirrious.CrossCore; 

namespace mvxTest.Core 
{ 

    public class MapViewModel : MvxViewModel 
    { 
      private IMvxLocationWatcher _watcher; 

      public MapViewModel (IMvxLocationWatcher watcher) 
      { 
        // var resolved = Mvx.CanResolve<IMvxLocationWatcher>(); // returns false 
        _watcher.Start (new MvxLocationOptions(), OnSuccess, OnError); 
      } 
    } 
} 



// my view 
using System; 
using Cirrious.MvvmCross.Touch.Views; 
using MonoTouch.UIKit; 
using System.Drawing; 
using Cirrious.MvvmCross.Binding.BindingContext; 
using mvxTest.Core; 

namespace mvxTest.Touch 
{ 

// http://www.youtube.com/watch?v=MM9iQlx3quA 
public class MapView : MvxViewController 
{ 
    public MapView() 
    { 
    } 

    public override void ViewDidLoad() 
    { 
     base.ViewDidLoad(); // <-- breaks here with complaints 

     var label = new UILabel (new RectangleF (0, 100, 100, 50)); 
     label.BackgroundColor = UIColor.Blue; 
     Add (label); 

     var edit = new UITextView (new RectangleF (0, 200, 100, 50)); 
     edit.BackgroundColor = UIColor.Green; 
     Add (edit); 

     var binding = this.CreateBindingSet<MapView, MapViewModel>(); 
     binding.Bind (label).To ((v) => v.Lat); 
     binding.Bind (edit).To ((v) => v.Lng); 
     binding.Apply(); 
    } 
} 
} 

錯誤是混亂的,因爲它提到視圖模型的依賴性不解決,但是誤差在視圖中拋出時觸發事件viewDidLoad中。也許它的視圖模型被加載。無論如何,爲什麼不注入依賴關係 - 我懷疑插件需要在monotouch項目中註冊。

2013-10-31 21:45:21.291 mvxTestTouch[9806:80b] mvx: Diagnostic: 0.20 Showing ViewModel MapViewModel 
2013-10-31 21:45:21.294 mvxTestTouch[9806:80b] TouchNavigation: Diagnostic: 0.20 Navigate requested 
2013-10-31 21:45:21.400 mvxTestTouch[9806:80b] mvx: Warning: 0.31 Problem creating viewModel of type MapViewModel - problem MvxException: Failed to resolve parameter for parameter watcher of type IMvxLocationWatcher when creating mvxTest.Core.MapViewModel 
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00000] in <filename unknown>:0 
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x00000] in <filename unknown>:0 
at Cirrious.CrossCore.Mvx.IocConstruct (System.Type t) [0x00000] in <filename unknown>:0 
at Cirrious.MvvmCross.ViewModels.MvxDefaultViewModelLocator.TryLoad (System.Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxViewModel& viewModel) [0x00000] in <filename unknown>:0 

// UPDATE

感謝您的建議斯圖爾特 - 看N31 + N8 N9的+位,我已經包括在觸摸項目LocationPluginBootstrap和共享相同的命名空間,它的偉大工程後 - THANKS !!:

using Cirrious.CrossCore.Plugins; 
using Cirrious.MvvmCross.Plugins.Location; 
using Cirrious.MvvmCross.Plugins.Location.Touch; 

namespace mvxTest.Touch 
{ 
    public class LocationPluginBootstrap 
    : MvxLoaderPluginBootstrapAction<PluginLoader,Plugin> 
    { 
    } 
} 

回答