Comments (12)
Can confirm workaround works: https://github.com/StanleyGoldman/UnderstandReactiveUIProblem/tree/validation-fix
Contribute to StanleyGoldman/UnderstandReactiveUIProblem development by creating an account on GitHub.
from reactiveui.validation.
Hey @Micha-kun 👋,
Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider backing us.
https://opencollective.com/reactiveui
PS.: We offer
priority
support for all backers. Don't forget to addpriority
label when you start backing us 😄
An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms!
from reactiveui.validation.
Hi @Micha-kun are you able to provide a small repository with a sample of your problem?
from reactiveui.validation.
Hi @glennawatson I filled about the bug with new info. I'll try to make that repository later and share with you.
Thank you
from reactiveui.validation.
Here is the repository sample:
https://github.com/Micha-kun/ReactiveUI.Validation.BugTest
Contribute to Micha-kun/ReactiveUI.Validation.BugTest development by creating an account on GitHub.
from reactiveui.validation.
I found that if I create the ValidationContext instance with RxApp.TaskpoolScheduler, it works as expected. By default it uses RxApp.MainThreadScheduler and, with this scheduler it doesn't refresh... Maybe in WinForms it requires to use TaskpoolScheduler as default?
from reactiveui.validation.
I found the same problem working in WPF, if i use the ValidationContext with RxApp.TaskpoolScheduler on my abstract class it works as expected, else throws ArgumentOutOfRangeException.
Without using an abstract class, with all the properties declared on the validated ViewModel it works with RxApp.MainThreadScheduler.
Special Characteristics:
- ReactiveUI.Validation version is 1.2.1
- Project target .NET Framework 4.7.2
- WPF project is a C# project.
- ViewModel project is a C# project.
from reactiveui.validation.
I recently hit this issue and I have a repro: https://github.com/StanleyGoldman/UnderstandReactiveUIProblem/tree/validation
Contribute to StanleyGoldman/UnderstandReactiveUIProblem development by creating an account on GitHub.
from reactiveui.validation.
If you set the ViewModel after resolving the main thread queue, no exception will occur.
internal class Program
{
[STAThread]
public static void Main()
{
var app = new App();
var vm = new MainWindowViewModel();
var window = new MainWindowView();
Service.DoEvennts();
window.ViewModel = vm;
app.Run(window);
}
}
public static class Service
{
[SecurityCritical]
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void DoEvennts()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback(ExitFrames), frame);
Dispatcher.PushFrame(frame);
}
public static object ExitFrames(object f)
{
((DispatcherFrame)f).Continue = false;
return null;
}
}
from reactiveui.validation.
I want IObservableList to be published as a public property.For simple collection access, you can use IObservableList .Items.
The problem of scheduler is caused by using ReadOnlyObservableCollection .I think that scheduler-aware coding, including creation of ReadOnlyObservableCollection, should be done by library users.
Currently I use the following extension methods for binding to a View.
public static IObservable<IList<ValidationState>> ResolveValidationStatusChanges<TViewModel, TViewModelProperty>(
this TViewModel vm,
Expression<Func<TViewModel, TViewModelProperty>> viewModelProperty,
bool exclusively = true)
where TViewModel : ReactiveObject, IValidatableViewModel
{
var field = typeof(ValidationContext).GetField("_validationSource", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance);
var sourcelist = (SourceList<IValidationComponent>)field.GetValue(vm.ValidationContext);
IObservableList<IValidationComponent> observableList = sourcelist.AsObservableList();
return observableList
.Connect()
.ToCollection()
.Select(c => Observable.CombineLatest(c
.OfType<BasePropertyValidation<TViewModel, TViewModelProperty>>()
.Where(x => x.ContainsProperty(viewModelProperty, exclusively))
.Select(x => x.ValidationStatusChange)))
.Switch();
}
ViewModel.ResolveValidationStatusChanges(x => x.IpAddress)
.Select(x => string.Join(",", x.Where(b => !b.IsValid).SelectMany(b => b.Text)))
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, v => v._test.Text)
.DisposeWith(d);
from reactiveui.validation.
This should have been fixed in #82. With ReactiveUI.Validation
from the main
branch, the ArgumentOutOfRangeException
is no longer thrown in BindValidation
, and the ValidationContext
is performing as expected, at least in my WPF playground 🎉 Feel free to reopen if you stumble upon this again.
from reactiveui.validation.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from reactiveui.validation.
Related Issues (20)
- feature: Add Xamarin.Android Sample App HOT 2
- feature: Make `ValidationText` immutable, and add `Empty` property. HOT 2
- [BUG] NullReferenceException when using `ReactiveValidationObject` HOT 1
- [BUG] Build failure for uap10.0.17763 target HOT 3
- Make Add and Clear operations immutable. HOT 3
- feature: Add ValidationRule extensions method overloads to accept any object implementing IValidationState HOT 1
- bug: Make nullability warnings errors HOT 2
- [Question] Correct data validation with collection HOT 3
- WPF ValidationRule is not working when call ShowDialog HOT 2
- [Question] How to use ReactiveValidationObject and INotifyDataErrorInfo in WPF HOT 6
- WPF ValidationRule is not working when ShowDialog window HOT 2
- BindValidation throws System.NotSupportedException HOT 4
- feature: Add a MAUI app to samples HOT 2
- [BUG] readme says to use ValidationRule on ReactiveValidationObject but it doesn't exist HOT 5
- [Question] Initial List Validation / Getting IsValid HOT 1
- feature: Bind validation to non-string view properties
- [Bug]: ReactiveValidationObject doesnt work with latest DynamicData version HOT 3
- feature : Multiple validation context support
- [Bug]: HasErrors is incorrect when performing a side effect from WhenAnyPropertyChanged
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveui.validation.