Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Simplify Attached Property Syntax #5487

Closed
ghost opened this issue Mar 7, 2019 · 2 comments
Closed

[Enhancement] Simplify Attached Property Syntax #5487

ghost opened this issue Mar 7, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 7, 2019

Summary

Attached properties are great when it comes to extending existing control functionality without inheritance but the problem with them is lengthy syntax especially for custom attached property.

So this can be replace
<Button material:Button.ButtonStyle="Outline"></Button>
with
<Button ButtonStyle="Outline"></Button>

API

I can think of two API options for this(not sure even if it is possible or not)
x:using="Visual.Material.AttachedProperties, OtherClasses" in XAML
or
[assembly:GlobalAttached(Visual.Material.AttachedProperties, OtherClasses)] in C#

Intended Use Case

One use case of this is to provide a simplified way to extend Entry, Button etc for Material API like #5005

@ghost ghost added the t/enhancement ➕ label Mar 7, 2019
@ghost ghost changed the title [Enhancement] Simply Attached Property Syntax [Enhancement] Simplify Attached Property Syntax Mar 7, 2019
@ghost
Copy link
Author

ghost commented Mar 9, 2019

I did some research and looked into the code of how Xamarin parses XAML. The problem with this enhancement is that <Button ButtonStyle="Outline" /> will be invalid xml and I think this is not wise.

Maybe what we can do, we can create a build task which will replace <Button ButtonStyle="Outline"/> with <Button material:Button.ButtonStyle="Outline"/>. Hence ButtonStyle="Outline" will be just syntactical sugar. We can run this task before XamlGTask.

@StephaneDelcroix
Copy link
Member

@pranshaggarwal we can't use invalid XAML, eve if we validify it before processing. the reason is that it'd break all the tooling around Xaml, like intelisense, previewer, 3rd party hot-reload solutions...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants