maui
maui copied to clipboard
Frame style in App class ignored
Description
Im creating a default style for Frame to remove corner radius and adding to the App.Resources dictionary. But the style isn't picked up.
Steps to Reproduce
New Maui app, add a frame to a page so you can see it.
In the App class, add the following code to the constructor:
var frameStyle = new Style(typeof(Frame))
{
Setters =
{
new Setter { Property = Frame.CornerRadiusProperty, Value = 0 }
}
};
Resources.Add("frameStyle", frameStyle);
I would expect the frame to have a zero for corner radius but is ignored. Interestingly Resources is already set and contains values, where in XF the instructions tell us to create a new ResourceDictionary. If I do that then many other controls will look wrong for the existing default settings.
In Maui how should this work? I want to set a global style at the app level.
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android, didn't try other platforms
Did you find any workaround?
Not really, creating a new Resources dictionary and added the style to that works, but then labels aren't appearing correctly.
Relevant log output
No response
Possible work-around is to create new dictionary, then use MergedDictionaries to append to existing one.
But I wouldn't expect that to work any better than what you did.
I wonder if doing it in the constructor is "too early". Perhaps there is a default Frame style that gets added by Maui "after" that.
repro with vs main build 32607.514
@jsuarezruiz when might this get picked up? It is disheartening to see so many simple issues not being resolved in a timely manner.
@jfversluis can you confirm how/if this should work? We have a lot of default styles setup this way in Xamarin Forms, if this isn't how we should be doing it Maui then what is the correct way?
It would greatly help if you could add a little reproduction project to see how this all fits together and make sure we're looking at the right thing.
Is this only happening for a Frame or also others? Did you remove the default styling in the template that is in place for a File > New Project? Is this happening only on Android or also others?
Hi @JohnHDev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@jfversluis I have just pulled the original code, upgraded to .net 7, and it is all working now as expected.
We can now migrate from Frame to Border, andI can now set a default style for all Border instances (and derived types) to work around a separate issue where Border doesn't occupy the same space as a Frame, but it does mean we can take another look at Maui.
Thanks! John
Perfect, thanks for letting us know!