diff --git a/ReactiveUI/PropertyBinding.cs b/ReactiveUI/PropertyBinding.cs index cbcccf195b..13cdecdd26 100644 --- a/ReactiveUI/PropertyBinding.cs +++ b/ReactiveUI/PropertyBinding.cs @@ -656,7 +656,7 @@ public IReactiveBinding> Bind true), + Reflection.ViewModelWhenAnyValueDynamic(viewModel, view, vmPropChain).Select(_ => true), signalInitialUpdate.Select(_ => true), signalViewUpdate != null ? signalViewUpdate.Select(_ => false) : @@ -777,7 +777,6 @@ public IReactiveBinding OneWayBind); var fallbackWrapper = default(Func); @@ -794,7 +793,7 @@ public IReactiveBinding OneWayBind { object tmp; if (!converter.TryConvert(x, viewType, conversionHint, out tmp)) return Observable.Empty(); @@ -817,7 +816,7 @@ public IReactiveBinding OneWayBind { object tmp; if (!converter.TryConvert(x, typeof(TVProp), conversionHint, out tmp)) return Observable.Empty(); @@ -894,13 +893,13 @@ public IReactiveBinding OneWayBind (TProp)x).Select(selector); } else { viewPropChain = Reflection.ExpressionToPropertyNames(viewProperty); var ret = evalBindingHooks(viewModel, view, vmPropChain, viewPropChain, BindingDirection.OneWay); if (!ret) return null; - source = Reflection.ViewModelWhenAnyValue(viewModel, view, vmProperty).Select(selector); + source = Reflection.ViewModelWhenAnyValueDynamic(viewModel, view, vmPropChain).Select(x => (TProp)x).Select(selector); } IDisposable disp = bindToDirect(source, view, viewProperty, fallbackValue); diff --git a/ReactiveUI/ReactiveList.cs b/ReactiveUI/ReactiveList.cs index bc25a79538..4970d97671 100644 --- a/ReactiveUI/ReactiveList.cs +++ b/ReactiveUI/ReactiveList.cs @@ -162,7 +162,6 @@ protected void RemoveItem(int index) if (ChangeTrackingEnabled) removeItemFromPropertyTracking(item); } -#if !SILVERLIGHT protected void MoveItem(int oldIndex, int newIndex) { var item = _inner[oldIndex]; @@ -186,7 +185,7 @@ protected void MoveItem(int oldIndex, int newIndex) _changed.OnNext(ea); if (_itemsMoved.IsValueCreated) _itemsMoved.Value.OnNext(mi); } -#endif + protected void SetItem(int index, T item) { if (_suppressionRefCount > 0) { diff --git a/ReactiveUI/Reflection.cs b/ReactiveUI/Reflection.cs index 34974ba7ed..1f8e0729c1 100644 --- a/ReactiveUI/Reflection.cs +++ b/ReactiveUI/Reflection.cs @@ -285,7 +285,16 @@ internal static IObservable ViewModelWhenAnyValue x.ViewModel, x => x.Value) .Where(x => x != null) - .SelectMany(x => ((TViewModel)x).WhenAny(property, y => y.Value)); + .SelectMany(x => Reflection.ExpressionToPropertyNames(property).Length == 0 ? Observable.Return((TProp)x) : ((TViewModel)x).WhenAny(property, y => y.Value)); + } + + internal static IObservable ViewModelWhenAnyValueDynamic(TViewModel viewModel, TView view, string[] property) + where TView : IViewFor + where TViewModel : class + { + return view.WhenAny(x => x.ViewModel, x => x.Value) + .Where(x => x != null) + .SelectMany(x => property.Length == 0 ? Observable.Return(x) : ((TViewModel)x).WhenAnyDynamic(property, y => y.Value)); } internal static FieldInfo GetSafeField(Type type, string propertyName, BindingFlags flags)