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

The AttachProperty which is bound did not work when the lib's xaml prefix is different from app's xaml prefix #9316

Open
vsfeedback opened this issue Jun 27, 2024 · 4 comments
Labels
📭 waiting-author-feedback To request more information from author.

Comments

@vsfeedback
Copy link

vsfeedback commented Jun 27, 2024

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice]

aa


Original Comments

Feedback Bot on 11/6/2023, 08:02 AM:

(private comment, text removed)

Ann Yang [MSFT] on 11/6/2023, 01:06 PM:

(private comment, text removed)

聪 李 on 11/6/2023, 02:12 PM:

(private comment, text removed)

Feedback Bot on 11/6/2023, 03:13 PM:

(private comment, text removed)

Feedback Bot on 2/5/2024, 00:15 PM:

(private comment, text removed)


Original Solutions

(no solutions)

Repro - AttachPropertyIssue.zip

@miloush

This comment was marked as outdated.

@MichaeIDietrich
Copy link
Contributor

MichaeIDietrich commented Jun 27, 2024

Please change the Binding in your Style from
{Binding (attaches:MyAttachProperty.MyImageSource),RelativeSource={RelativeSource Self}} to
{Binding Path=(attaches:MyAttachProperty.MyImageSource),RelativeSource={RelativeSource Self}}
to fix this issue.

new Binding(xyz) and new Binding() { Path=xyz } are not equivalent.
The former interprets the path as a plain string where it is not able to understand the explicit property syntax.
While the latter interprets the path as PropertyPath which correctly resolves that syntax.

In C# code you can explicitly pass a PropertyPath to the constructor of a Binding, but you cannot in XAML and therefore must use the Path property on Binding.

I can only make guesses why both things behave differently here. But in general I would just recommend to just always use the Path property on a Binding in XAML.

@miloush
Copy link
Contributor

miloush commented Jun 27, 2024

Hm I tried again and I can no longer reproduce the setter failure I was claiming ("Setter Property="attaches:..."), I must have had the binding still around. Thanks Michael!

The string constructor seems to be able to deal with explicit property syntax, I think it goes through the same parsing codepath, but it doesn't get the XAML context to map the namespaces. Theoretically we could make the ProvideValue fix the Path property, but then it would behave differently in code and in markup, which is probably not great.

@himgoyalmicro himgoyalmicro added the 📭 waiting-author-feedback To request more information from author. label Jun 28, 2024
@lindexi
Copy link
Contributor

lindexi commented Jun 29, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📭 waiting-author-feedback To request more information from author.
Projects
None yet
Development

No branches or pull requests

5 participants