ToProperty() appears to be used for read-only properties that are based on observables but when would I want to use BindTo()?
ToProperty is for ViewModels, whereas BindTo is a bit more flexible and is intended to be used in the View layer of your applications. For example (this specific use-case isn't actually a best practice, but it's a good example):
this.WhenAny(x => x.ViewModel.IsTextEnabled)
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
.BindTo(this, x => x.TextBox.Visibility);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With