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

Binding context type check fails for relative binding sources #25608

Open
simonrozsival opened this issue Oct 30, 2024 · 0 comments · May be fixed by #25600
Open

Binding context type check fails for relative binding sources #25608

simonrozsival opened this issue Oct 30, 2024 · 0 comments · May be fixed by #25600
Labels
area-xaml XAML, CSS, Triggers, Behaviors i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 t/bug Something isn't working
Milestone

Comments

@simonrozsival
Copy link
Member

simonrozsival commented Oct 30, 2024

Description

When we check for x:DataType and binding context mismatch when a Binding is applied, we compare the x:DataType with an instance of RelativeBindingSource instead of the resolved source object.

As a result, the runtime log contains misleading warnings:

Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: Mismatch between the specified x:DataType (Microsoft.Maui.Controls.VerticalStackLayout) and the current binding context (Microsoft.Maui.Controls.RelativeBindingSource).

Steps to Reproduce

Starting from dotnet new maui:

  1. Enable $(MauiEnableXamlCBindingWithSourceCompilation) in project file:
<PropertyGroup>
    <MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>
</PropertyGroup>
  1. Add a binding with relative source and x:DataType to MainPage.xaml:
<VerticalStackLayout Spacing="25">
      <Image
          Source="dotnet_bot.png"
          HeightRequest="{Binding Spacing, x:DataType=VerticalStackLayout, Source={RelativeSource AncestorType={x:Type VerticalStackLayout}}}" />
</VerticalStackLayout>

Link to public reproduction project repository

No response

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.0-rc.2.24503.2

Affected platforms

iOS, Android, Windows, macOS, Other (Tizen, Linux, etc. not supported by Microsoft directly)

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@simonrozsival simonrozsival added area-xaml XAML, CSS, Triggers, Behaviors t/bug Something isn't working labels Oct 30, 2024
@samhouts samhouts added platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 platform/android 🤖 platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 30, 2024
@PureWeen PureWeen added this to the .NET 9 SR1 milestone Oct 30, 2024
@PureWeen PureWeen added p/0 Work that we can't release without i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors i/regression This issue described a confirmed regression on a currently supported version p/0 Work that we can't release without platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst platform/windows 🪟 t/bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants