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

XAML Object Self Reference Gets Warning #25272

Closed
david-maw opened this issue Oct 15, 2024 · 5 comments
Closed

XAML Object Self Reference Gets Warning #25272

david-maw opened this issue Oct 15, 2024 · 5 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors i/regression This issue described a confirmed regression on a currently supported version s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@david-maw
Copy link

Description

With MauiEnableXamlCBindingWithSourceCompilation set, objects that self-refer get warning

XamlC warning XC0045: Binding: Property "property name" not found

For example, this XAML (which draws a circle of diameter MainViewModel.Diameter

            <Ellipse Stroke="Red"
                 Fill="White"
                 StrokeThickness="5"
                 WidthRequest="{Binding Diameter}"
                 HeightRequest="{Binding Source={RelativeSource Self},Path=WidthRequest}"
                 HorizontalOptions="Center"
                 VerticalOptions="End"
                 Margin="20"/>

gets the warning

XamlC warning XC0045: Binding: Property "WidthRequest" not found

Because Widthrequest is a property of the Ellipse class whereas Diameter is a property of the MainViewModel class which is specified in an enclosing page level x:DataType.

Steps to Reproduce

  1. Open the project from Git
  2. Build It
  3. Observe The Warning

Link to public reproduction project repository

https://github.com/david-maw/ItemSelfRef.git

Version with bug

9.0.0-rc.2.24503.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

I was not able test on other platforms

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@david-maw david-maw added the t/bug Something isn't working label Oct 15, 2024
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Oct 15, 2024
@jaosnz-rep jaosnz-rep added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed platform/windows 🪟 and removed platform/windows 🪟 labels Oct 15, 2024
@jaosnz-rep
Copy link

I can repro this issue at Windows platform on the latest 17.12.0 Preview 2.1(9.0.0-rc.2.24503.2 & 9.0.0-rc.1.24453.9).

@jsuarezruiz jsuarezruiz added the i/regression This issue described a confirmed regression on a currently supported version label Oct 15, 2024
@jsuarezruiz jsuarezruiz added this to the .NET 9 Planning milestone Oct 15, 2024
@simonrozsival
Copy link
Member

@david-maw in this case, the best way to do this is to specify the x:DataType directly on the {Binding} like this:

HeightRequest="{Binding Source={RelativeSource Self}, Path=WidthRequest, x:DataType=Ellipse}"

Does this solve your issue?

@StephaneDelcroix
Copy link
Contributor

very similar to #25271

@david-maw
Copy link
Author

I had not realized you could even do that, and VS autocomplete doesn't offer it yet!
I'll be a bit tedious to do, but I can do it, and until #21834 can be implemented, it'll do, thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors i/regression This issue described a confirmed regression on a currently supported version s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants