microsoft / xaml-standard

XAML Standard : a set of principles that drive XAML dialect alignment
Other
805 stars 50 forks source link

Expose a "Text" property to all button controls (Button,RadioButton...) for UWP #153

Closed gillesmessier closed 7 years ago

gillesmessier commented 7 years ago

For two reasons 1) Unify usage of all controls where the Text and Content properties behave the same when just assigning a simple string value. I think Xamarin.Forms does it right actually. 2) Simplify a bit the actual localization process forcing you to duplicate a resource string for different control types. Actually you have to define two strings: one for the Content property of a Button and another for the Text property of a TextBox. Example of a Resource.resw file (one for each supported language)

Name Value Comment
str_Refresh.Text Mettre à jour
str_Refresh.Content Mettre à jour

Note: the Content property of all button controls could be preserved and behave as it is; I am asking to expose a complementary Text property.

skendrot commented 7 years ago

Disagree with this. Button can have anything for it's Content. After all, it is a ContentControl. A Button is not limited to just Text.

gillesmessier commented 7 years ago

I am not asking to remove the Content property. Just expose a supplementary property.

dotMorten commented 7 years ago

I also don't like this. Having two properties that does the same thing is bad. If I set the content to a TextBlock, what value does the 'Text" property have? And what if I set it to an image? What happens if I set both?

insinfo commented 7 years ago

Could be like that: If the "content" property has been set this overrides the "text" property. If the "content" property has not been defined, what will prevail is the "text" property.

insinfo commented 7 years ago

Thinking better, forget what I said up ahead. I think this is going to complicate things, maybe it's better to just have the "content" property

skendrot commented 7 years ago

You should close the issue if no longer valid

gillesmessier commented 7 years ago

Humm...right I can circumvent the duplicate resources problem by systematically transforming all: <Button x:Uid="str_Refresh" Content="Refresh" /> to <Button> <TextBlock x:Uid="str_Refresh" Text="Refresh"/> </Button> Hence there is no more need for the str_Refresh.Content definition. This workaround is working very well. With this there is no need to expose any Text property. Thank you all you were right.