-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Migrating Color and VisualStateManager #6454
Comments
verified repro on android 11 and windows with the above project. |
could you be specific on what isn't working for you ? |
Sorry, I thought I was being specific, the part of the issue description beginning "Comparing the code in The preceding section tries to illustrate the effect of the changes. In general just try and convert the Xamarin Is there some specific area of my description that's unclear? |
@StephaneDelcroix Just noticed I didn't specifically mention you in the previous comment so I'm doing so now in case you didn't see my response. |
@StephaneDelcroix I am looking at converting a project that uses Color.Default so this is a real issue. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 5.0. Can repro on windows and android platform with sample project. |
Description
The behavior of Color and VisualStateManager in MAUI is sufficiently different that migration is challenging. I've commented on some aspects of this before (see issue #1668) but the combination of several design decisions makes migration especially painful.
The attached example, a simple single page application with a label and 3 entry fields shows some of the issues.
Steps to Reproduce
Comparing the code in
MainPage.xaml.cs
between Xamarin and MAUI the significant changes are:Color
literals becomeColors
literals, this is annoying, but relatively easy to change, still it would be nice to provide migration code and it's not clear to me why this change was necessary at all (see Issue [Enhancement] Provide Migration guidance for Xamarin.Forms.Color #1668 for more on this).There is no direct equivalent of
Color.Default
, pull request Don't extract native defaults, meaning users can no longer reset a color back to a platform theme #1485 says this is by design but that makes migrating platform independent code difficult (new code is obviously easier). I suggest some migration scheme at least be provided rather than punting to the MAUI programmer to learn enough device dependencies to extract the value for themselves. I expect there's a similar problem withColor.Accent
. Issue Don't extract native defaults, meaning users can no longer reset a color back to a platform theme #1485 says "For now we are going to operate on the premise that users don't use the behavior ofColor.Default
enough to warrant the effort of implementation and the performance implications of pulling those values during startup." But delaying evaluating it until it is requested would remove that overhead for programs that did not use it (written as a man who doesn't have to code it, I agree).The other issues are with the XAML and especially with the VisualStateManager implementations. The first VisualStateManager sets an Entry background color in a
Focused
state and specifies nothing for aNormal
state which means switching back to aNormal
state sets BackGroundColor to null. Taken in conjunction with pull request #1485 this means the switch back is ignored and theSelected
background color persists. Again for new code there's a fairly easy workaround, for existing code it's trickier.Finally, there are the other functional differences in the MAUI version of the sample:
Version with bug
Release Candidate 1 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
Android 11, Windows 10
Did you find any workaround?
Sometimes. See above (and the code)
Relevant log output
No response
The text was updated successfully, but these errors were encountered: