-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
multiple scenarios how views can get out of sync when trying to validate and fix user inputs #446
Comments
The signaler isn't intended to be a fix for binding problems. I disagree with the recommendations in the issues/posts that you linked. The signaler's purpose is to signal binding updates for events that aren't "property change" or "collection mutated" related (eg the current time changed or the current locale changed). Although it's tempting to try and make a numeric input control using only a value converter, in practice, it's not enough. A custom element is the preferred way to create input controls. With a custom element you get to decide when to update the bindable "value" property and with what value. Value converters don't have the same degree of flexibility and have no way to add "behavior". #442 mentions changes being "reverted" when they actually never happen due to the setter not accepting the value. This means no change notification or binding update happens as a result. |
Thanks Jeremy for taking your time. As you also recognised it's very tempting to use the valueConverter to convert values when they are written back to the model ;) In 90% of the cases when i use the fromView() Method i ran into the sync issue mentioned here. So your answer implies that i need to create different custom elements just for the sake of a "clean" dataentry? In my case this would mean that i should create a custom element for:
I don't have a problem with that because i'll avoid valueConverter-fromView() from now on and i'm able to create those custom-elements. But i'm a bit scared that fresh users will also run into this and generate Issues. I clearly prefer the View Update because the work already done with fromView() and propertyChanged() would be much,much more useful then. So i would like to keep this issue open. Btw. i recognised that the value converter gist didn't show off the issue nicely. i've changed it: |
@jdanyow @EisenbergEffect could you please reopen this issue? |
just another "view not updated" issue: |
@fopsdev No need to duplicate #442 or #353. Please continue the relevant parts of this discussion in those issues. Here's a simple number-input element and number-value attribute. I hope these will help illustrate why a custom elements/attributes are a better fit for accepting numeric/date/etc input. |
i understand. thanks |
Closing as a duplicate of other issues listed above. We'll try to clarify some explanations in our documentation so that ValueConverter to get used for the wrong purpose. |
I'm just showing how easy the view can be brought out of sync using existing out of the box concepts.
Please have in mind that i really like to expose my models directly to the ui and i don't like to work on clones or use other development patterns. Thats why i add some validation to keep them clean.
valueConverters:
https://gist.run/?id=0ae5f6f0ff127e404c9076dce866902d
changeHandler:
https://gist.run/?id=f2fae5b7695b76a3c820caaa4bced084
Similar Issues and their solutions :
All the following issues are related to simple validation scenarios.
The solutions are technically brilliant and appreciated but i think there should be an easier way to accomplish this
#353
Solution: Additional usage of a Signaler
#442
Solution: Additional usage of a Signaler
http://stackoverflow.com/questions/37882659/force-view-to-be-updated-from-within-a-valueconverter/37890664#comment63703880_37890664
Solution: Additional Signaler, BindingBehaviour, CustomElement
Btw. this posts mention some other use cases as well
So long story short:
After changing a value which goes to the model (be it from the valueConverter or in the changedHandler) the view should be updated as well
The text was updated successfully, but these errors were encountered: