diff --git a/src/client/spark/core/Utility/ViewModelBase.cs b/src/client/spark/core/Utility/ViewModelBase.cs index e22ae3284..eb801c4a2 100644 --- a/src/client/spark/core/Utility/ViewModelBase.cs +++ b/src/client/spark/core/Utility/ViewModelBase.cs @@ -22,6 +22,16 @@ namespace mbts.ui.shell { void clear_error(string property); } + interface IProperty : IObservable<(T oldval, T newval)> { + event PropertyChange Changing, Changed; + T Value { get; set; } + } + + interface IUserProperty : IProperty { + bool setter_called { get; } + void bypass_setter(T value); + } + public delegate void PropertyChange(T oldval, T newval); static class ValidationViewModelExtensions { @@ -159,7 +169,7 @@ namespace mbts.ui.shell { protected DelegatePropertyAutoWrapper backing(string name, Func get_model, Func convert) => new DelegatePropertyAutoWrapper(this, name, get_model, convert, EqualityComparer.Default); - protected class Property : IObservable<(T oldval,T newval)> { + protected class Property : IProperty { readonly string _propname; readonly IEqualityComparer _comparer; readonly ViewModelBase _owner; @@ -300,7 +310,7 @@ namespace mbts.ui.shell { /// A thin wrapper around Property<T> that trips a 'setter_called' flag when the value is set through value-property-setter (i.e., through User interaction). /// Note: This is class is particularly useful when a default/settings-based value arrives late, and the viewmodel must decide whether or not to override the current value. /// - protected class UserProperty : IObservable<(T oldval, T newval)> { + protected class UserProperty : IUserProperty { readonly Property _prop_model; public UserProperty(Property prop_model) =>