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

How to force Binding.addValidation upon returning to wpf usercontrol? #593

Open
awaynemd opened this issue Jan 10, 2024 · 3 comments
Open

Comments

@awaynemd
Copy link

My wpf window is setup to switch between multiple usercontrols. Upon first showing of the first usercontrol, the bindings are correctly read and the addValidation code called resulting in red boxes around invalid textblocks.

I then switch to the second user control such that the first user control is no longer visible. All works well.

However, when I return to the first usercontrol with the invalid textblock, the red box surrounding the invalid data is no longer visible.

How can I force validation without a change in data on the first usercontrol (to again show the invalid red box) ?

Note: Microsoft recommends ValidatesOnTargetUpdated="True" , is this implemented in Elmish.wpf?

Thanks for any help or suggestions.

@awaynemd
Copy link
Author

It would be great if I could tie a command to the GotFocus() event that would go through all the validation code on the bindings for a usercontrol. Does such a thing exist?

Thans again

@awaynemd
Copy link
Author

An easy solution to the above problem seems to be to put around the main grid/panel within each usercontrol. Doing so allows the validation code to be run once and the red error border to be maintained between usercontrol switches.

I'd still be interested to know about ValidatesOnTargetUpdated though.

Thanks.

@TysonMN
Copy link
Member

TysonMN commented Jan 15, 2024

Note: Microsoft recommends ValidatesOnTargetUpdated="True" , is this implemented in Elmish.wpf?

Can you share a link to Microsoft's recommendation?

My guess is that this is a property that you can set in your XAML code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants