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

Data entry field tracking list has wrong BindingContext value #5437

Closed
david-maw opened this issue Mar 19, 2022 · 4 comments
Closed

Data entry field tracking list has wrong BindingContext value #5437

david-maw opened this issue Mar 19, 2022 · 4 comments
Assignees
Labels
legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor p/0 Work that we can't release without platform/android 🤖 platform/windows 🪟 s/not-a-bug This isn't actually a bug, or is working as expected s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage
Milestone

Comments

@david-maw
Copy link

david-maw commented Mar 19, 2022

Description

When a CollectionView is bound to a list of items and an entry field is bound to a property of the selected item the correct information is shown in the entry field and it changes as the selection changes, all as expected. However if there's a method attached to the Unfocused event on the Entry it is called with the wrong BindingContext value (it looks like it may be the one inherited from the page rather than the selected item used to display the value)

Steps to Reproduce

  1. Unzip the attached project
  2. Run it on Windows or Android
  3. Select an item in the list to get the entry field prefilled
  4. select the entry field and change it
  5. select a different item, the value you entered should appear in the item previously selected, it won't
  6. put a breakpoint at the end of Entry_Unfocused and repeat the test and you'll see the BindingContext value is not as expected (it will be a LineItemView not a LineItem)

Sample project:
MAUIListEntry-Binding.zip

Version with bug

Preview 14 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Android 11, Windows 10

Did you find any workaround?

No response

Relevant log output

No response

@david-maw david-maw added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Mar 19, 2022
@PineYi PineYi added the s/triaged Issue has been reviewed label Mar 21, 2022
@v-longmin
Copy link

v-longmin commented Mar 21, 2022

Verified the issue on windows, it's repro.
MAUIListEntry-Binding.zip

@v-longmin v-longmin added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Mar 21, 2022
@PineYi PineYi removed the s/triaged Issue has been reviewed label Mar 21, 2022
@v-longmin v-longmin added the s/triaged Issue has been reviewed label Mar 21, 2022
@Redth Redth added this to the 6.0.300 milestone Mar 21, 2022
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Mar 28, 2022
@davidortinau davidortinau added the p/0 Work that we can't release without label Apr 29, 2022
@Redth Redth self-assigned this May 2, 2022
@Redth Redth added s/not-a-bug This isn't actually a bug, or is working as expected and removed t/bug Something isn't working labels May 2, 2022
@Redth
Copy link
Member

Redth commented May 2, 2022

The entry's bindingcontext in this sample project is never changed, so it is correctly set to that of its parent, which is in this case, LineItemView. While you are setting the Entry's Text property to that of the SelectedItem.ItemName via the reference to LineItemsListView, this does not influence the binding context of the actual Entry itself.

@Redth Redth closed this as completed May 2, 2022
@david-maw
Copy link
Author

@Redth thanks, you're correct, that example is just not right, sorry. I must have screwed something up when I stripped down the original (a chunk of code embedded in a large Xamarin Forms application I'm experimentally migrating to MAUI). I'll go back to the original code and see if I can come up with a better test case - if I'm lucky the original problem I noticed on preview 14 has been fixed in the meantime.

@david-maw
Copy link
Author

@Redth well, that test turned out easier than I expected, it was a bug in the original code. It didn't work in Xamarin forms either, it's just that nobody had ever noticed. Thanks for your help debugging my code! Now, if someone will just implement #5596 I won't need to fix it 😉

@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor p/0 Work that we can't release without platform/android 🤖 platform/windows 🪟 s/not-a-bug This isn't actually a bug, or is working as expected s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage
Projects
None yet
Development

No branches or pull requests

7 participants