diff --git a/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs b/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs index 84392750b5..3a45b96d98 100644 --- a/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs +++ b/src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs @@ -21,6 +21,7 @@ public class PropertyBindViewModel : ReactiveObject private decimal _JustADecimal; private double? _NullableDouble; private int _JustAInt32; + private bool _JustABoolean; public PropertyBindViewModel(PropertyBindModel? model = null) { @@ -46,6 +47,12 @@ public double JustADouble set => this.RaiseAndSetIfChanged(ref _JustADouble, value); } + public bool JustABoolean + { + get => _JustABoolean; + set => this.RaiseAndSetIfChanged(ref _JustABoolean, value); + } + public decimal JustADecimal { get => _JustADecimal; diff --git a/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs b/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs index b28a8a737b..f6a56e0744 100644 --- a/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs +++ b/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs @@ -344,6 +344,16 @@ public void BindingToItemsControl() Assert.True(itemsSourceValue.OfType().Count() > 1); } + [Fact] + public void OneWayBindConverter() + { + var vm = new PropertyBindViewModel(); + var view = new PropertyBindView { ViewModel = vm }; + var fixture = new PropertyBinderImplementation(); + fixture.OneWayBind(vm, view, x => x.JustABoolean, x => x.SomeTextBox.IsEnabled, s => s); + Assert.False(view.SomeTextBox.IsEnabled); + } + [Fact] public void BindExpectsConverterFuncsToNotBeNull() { diff --git a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs index 1d1a78d20b..fe82427cd1 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs @@ -217,7 +217,7 @@ bool ViewToVmFunc(TVProp vValue, out TVMProp vmValue) return null; } - IObservable source = (IObservable)Reflection.ViewModelWhenAnyValue(viewModel, view, vmExpression).Select(x => (TProp)x).Select(selector); + IObservable source = Reflection.ViewModelWhenAnyValue(viewModel, view, vmExpression).Select(x => (object?)selector((TProp)x)); var (disposable, obs) = BindToDirect(source, view, viewExpression);