2015-08-09 21 views
1

我有非常简单的ReactiveObject ViewModel,其中属性为ReactiveObject s。在OneWayBind中在ReactiveUI中传播null

鉴于我有以下的结合:

this.OneWayBind(ViewModel, 
       vm => vm.CurrentEditor.SelectedTreeViewItem.ItemTitle, 
       v => v.CurrentSelectionImage.ToolTip); 

是否有可能工具提示设置为nullCurrentEditor成为null

回答

1

这是按照docs的预期行为。

有可能是一个更好的方式来实现它,但起码你可以使用WhenAnyValue并将其绑定到两个CurrentEditor CurrentEditor.SelectedTreeViewItem.ItemTitle:

ViewModel.WhenAnyValue(vm => vm.CurrentEditor, 
         vm => vm.CurrentEditor.SelectedTreeViewItem.ItemTitle, 
         (ce, title) => ce == null ? null : title) 
     .BindTo(this, v => v.CurrentSelectionImage.ToolTip); 
+1

我做这样的说法目前,但有时我得到4个元素在VhenAnyValue :) – kwesolowski