You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've researched the way how I can use implicit styles for custom components. Now I guess that it is not the best way because the custom implicit style (placed in the application or local resources) overrides my styles.
But faced one side effect, if I've place style to App.xaml resources it works - implicit styles work like merged. Looked at a code. That is caused by a sequence of calling:
For an example, I use the Button. First style placed in App.xaml, second - MainPage.xaml
Button.ctor calls NavigableElement.ctor and register implicit styles. App.xaml resources were loaded at that time and the OnImplicitStyleChanged raised immediately
The first style apply own setters to bindable the object and place a new value to _originalValues
OnParentResourcesChanged raise an updated implicit style
The second style applies. It calls the previous style UnApply which restores properties from Setter._originalValues
So, the Button has BackgroundColor from the first style and TextColor from the second.
Is that a behavior bug or an expected case? It works in MAUI and Xamarin.Forms for Android. Guess, my description is too hard, so I'm open to discussion.
This discussion was converted from issue #8460 on July 02, 2022 18:07.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I've researched the way how I can use implicit styles for custom components. Now I guess that it is not the best way because the custom implicit style (placed in the application or local resources) overrides my styles.
But faced one side effect, if I've place style to App.xaml resources it works - implicit styles work like merged. Looked at a code. That is caused by a sequence of calling:
Button
. First style placed in App.xaml, second - MainPage.xamlButton.ctor
callsNavigableElement.ctor
and register implicit styles. App.xaml resources were loaded at that time and theOnImplicitStyleChanged
raised immediately_originalValues
OnParentResourcesChanged
raise an updated implicit styleUnApply
which restores properties fromSetter._originalValues
BackgroundColor
from the first style andTextColor
from the second.Is that a behavior bug or an expected case? It works in MAUI and Xamarin.Forms for Android. Guess, my description is too hard, so I'm open to discussion.
Beta Was this translation helpful? Give feedback.
All reactions