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

Resolving an x:Reference in a RELEASE build picks the wrong element in some cases. #8149

Closed
Keflon opened this issue Jun 18, 2022 · 1 comment · Fixed by #8345
Closed

Resolving an x:Reference in a RELEASE build picks the wrong element in some cases. #8149

Keflon opened this issue Jun 18, 2022 · 1 comment · Fixed by #8345
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/android 🤖 platform/iOS 🍎 platform/windows 🪟 t/bug Something isn't working
Milestone

Comments

@Keflon
Copy link

Keflon commented Jun 18, 2022

Description

Repro project

https://github.com/Keflon/MauiNameBug

In a RELEASE build

Bindings to x:Name="Self" in a DataTemplate incorrectly resolve to child-controls if a child control also has x:Name="Self"

In a DEBUG build Bindings work as expected

Steps to Reproduce

  1. Create a File->New MAUI app
  2. Create a xaml 'child' ContentControl whose root element has x:Name="Self"
  3. Create a xaml 'Parent' ContentControl whose root element also has x:Name="Self"
    1. Add a CollectionView
    2. Add a DataTemplate to the CollectionView that instantiates the 'child' ContentControl
    3. Databind something in the DataTemplate to x:Reference Self
  4. Add the 'Parent' control to MainPage.xaml and populate the Parent CollectionView with some items.

In a DEBUG build, the Binding correctly resolves to an instance of the 'Parent' control
In a RELEASE build, the Binding incorrectly resolves to an instance of the 'Child' control

Version with bug

6.0.400 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows

Affected platform versions

Latest

Did you find any workaround?

If you give elements an x:Name, make them unique, including any names in 3rd-party controls.

Relevant log output

No response

@Keflon Keflon added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jun 18, 2022
@StephaneDelcroix
Copy link
Contributor

StephaneDelcroix commented Jun 20, 2022

probably a namescoping issue. the difference between DEBUG and RELEASE is that DEBUG uses runtime xaml inflation while RELEASE compiles the XAML ahead of time.

@StephaneDelcroix StephaneDelcroix self-assigned this Jun 20, 2022
@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Jun 20, 2022
@jfversluis jfversluis removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Jun 20, 2022
StephaneDelcroix added a commit that referenced this issue Jun 27, 2022
This allows correct x:Reference resolution in DataTemplates

- fixes #8149
StephaneDelcroix added a commit that referenced this issue Jun 27, 2022
This allows correct x:Reference resolution in DataTemplates

- fixes #8149
StephaneDelcroix added a commit that referenced this issue Jun 27, 2022
This allows correct x:Reference resolution in DataTemplates

- fixes #8149
StephaneDelcroix added a commit that referenced this issue Jun 28, 2022
This allows correct x:Reference resolution in DataTemplates

- fixes #8149
StephaneDelcroix added a commit that referenced this issue Jan 23, 2023
This allows correct x:Reference resolution in DataTemplates

- fixes #8149
mattleibow added a commit that referenced this issue Jan 23, 2023
* [X] Pass the parent scopes to DataContext

This allows correct x:Reference resolution in DataTemplates

- fixes #8149

* context.Cache

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Feb 22, 2023
@samhouts samhouts added this to the 8.0-preview1 milestone Feb 22, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/android 🤖 platform/iOS 🍎 platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants