2012-09-11 6 views
1

Я только что начал изучать ReactiveUI, но у вас есть некоторые проблемы.Не удалось найти ICreatesObservableForProperty для

В ReactiveObject, я пытаюсь сделать наблюдаемым на основе свойства ...

public class StudentListViewModel : ReactiveObject, IStudentListViewModel 
{ 
    public StudentListViewModel() 
    { 
     var observable = this.ObservableForProperty(x => x.SearchQuery); 
    } 

    string _SearchQuery; 
    public string SearchQuery 
    { 
     get { return _SearchQuery; } 
     set { this.RaiseAndSetIfChanged(x => x.SearchQuery, value); } 
    } 
} 

... что приводит к следующей ошибке:

Couldn't find a ICreatesObservableForProperty for MyApplication.ViewModels.StudentListViewModel. This should never happen, your service locator is probably broken.

я использовал Ninject в качестве DI, и попытался сказать ReactiveUI примерно так:

class Bootstrapper : IBootstrapper 
{ 
    public Bootstrapper() 
    { 
     Kernel = new StandardKernel(); 
     Kernel.Bind<IBootstrapper>().ToConstant(this); 
     Kernel.Bind<IScreen>().ToConstant(this); 
     Kernel.Bind<IViewFor<StudentListViewModel>>().To<StudentListView>(); 

     Router = new RoutingState(); 

     RxApp.ConfigureServiceLocator(
      (type, key) => Kernel.Get(type, key), 
      (type, key) => Kernel.GetAll(type, key), 
      (from, type, key) => 
       { 
        var binding = Kernel.Bind(from).To(type); 
        if (key != null) 
         binding.Named(key); 
       } 
      ); 
    } 
} 

Кто-нибудь видит p здесь?

ответ

1

Вы перешли 'от' и 'ключ':

RxApp.ConfigureServiceLocator(
     (type, key) => Kernel.Get(type, key), 
     (type, key) => Kernel.GetAll(type, key), 
     (from, type, key) => 
      { 
       var binding = Kernel.Bind(type /*this was from*/).To(from /*ditto*/); 
       if (key != null) 
        binding.Named(key); 
      } 
     ); 
+0

хороший улов. Благодарю. – Vegar

+0

Это слишком легко сделать, мне нужно сделать так, чтобы это было более очевидно, когда эта ошибка случается –

Смежные вопросы