Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to use ReactiveValidationObject and INotifyDataErrorInfo in WPF #237

Closed
lszczygielek opened this issue Mar 11, 2021 · 6 comments

Comments

@lszczygielek
Copy link
Contributor

lszczygielek commented Mar 11, 2021

Hi,
I'm playing with validation using INotifyDataErrorInfo and I'm very confused and I don't know how to use it properly. I couldn't find concrete info in documentation, only sample project gives me some clues, but I don't know if it is all what I should know.

Let's say that I want to make a TextBox and default ErrorTemplate (red border) should be visible if value is empty. Based on code from sample I'm suspecting that I have to:

  • bind TextBox Text to view-model using regular XAML binding,
  • in the code behind of view I have to bind using ReactiveUI a ViewModel to DataContext.

So in short - is there another way to use INotifyDataErrorInfo using only ReactiveUi bindings? Unfortunately I can't turn on INotifyDataErrorInfo in other way than regular XAML binding, documentation didn't help me in this topic, only sample application shows me how to do this in regular XAML.

@ScarletKuro
Copy link

ScarletKuro commented Mar 12, 2021

Is there another way to use INotifyDataErrorInfo using only ReactiveUi bindings?

No. The INotifyDataErrorInfo is only supported via XAML binding, it doesn't support BindValidation. But you can make your own extension method like here for WPF.

If i remember correct, the reason is because RxUI has it's own binding mechanism.
I also think there was idea to make platform depended libs like ReactiveUI.Validation.WPF to support it, but im not sure.

@glennawatson
Copy link
Collaborator

We listen and do the setting of the property ourselves in RxUI bindings, and don't use the inbuilt classes that WPF provides, it's more multi platform aware that way.

The downside is that INotifyDataErrorInfo relies on WPF inbuilt binding classes.

@glennawatson
Copy link
Collaborator

There's nothing stopping you from using the inbuilt WPF Bind with RXUI, we abstract it out into a ICreatesObservable interface so you could make sure of those classes behind the scenes.

Might be a future WPF/UWP package feature.

@lszczygielek
Copy link
Contributor Author

Thank you all for clarification.

@glennawatson what do you think about to add info that INotifyDataErrorInfo requires classic binding/connecting to build-in WPF mechanism? I can make PR with it but first I would like to know if this makes sense.

@lszczygielek
Copy link
Contributor Author

Documentation updated, so I'm closing this. Thank you all for your time in clarification and PR review.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants