Skip to content

[Bug]: ElementName binding inside a template is falsely reported as an error (WXAML0027) #351

Open

Description

Describe the bug

{Binding ElementName=X} inside a DataTemplate or ControlTemplate that targets a named element outside the template is reported as an Error, although it compiles and works at runtime.

To Reproduce

  1. In a page, add <TextBox x:Name="T" Text="outer-text"/>.
  2. Add a ListView with <DataTemplate><TextBlock Text="{Binding Text, ElementName=T}"/></DataTemplate>.
  3. See WXAML0027 No element named 'T' is visible in this XAML namescope.

Expected behavior

No diagnostic. dotnet build succeeds and the binding resolves at runtime.

Notes

Bug bash ID: C-05 (P1).

Screenshots

No response

OS Version and details

Windows 11 x64 (10.0.26200), VS Code 1.143.1, .NET SDK 10.0.403. Found in the XAML IntelliSense bug bash on 0.3.1-prerelease.456 (PR #276, f90df977).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugintellisense

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions