xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.88k forks source link

[Bug] ResourceDictionary implicit styles getting overwritten by Application.Resources implicit styles #11545

Open Xyotic opened 4 years ago

Xyotic commented 4 years ago

Description

Setting a views resources via a ResourceDictionary file will get its implicit styles overwritten by Application.Resources implicit styles in App.xaml.

Steps to Reproduce

  1. Create a implicit style in App.xaml Application.Resources.
  2. Create a ResourceDictionary.xaml file in your project and overwrite the implicit style.
  3. Use the ResourceDictionary.xaml in a view like ContentView or AbsoluteLayout

Expected Behavior

The style defined in ResourceDictionary.xaml gets used.

Actual Behavior

The style defined in App.xaml gets used.

Basic Information

Edit: For some reason the right style is choosen for elements inside a ListView

PureWeen commented 4 years ago

@StephaneDelcroix

rmarinho commented 4 years ago

Hi @Xyotic can you please provide a small reproduction sample so we can look better at this issue?

Thanks

Xyotic commented 4 years ago

If you run this project you will see the centered label will have a background color of red. (wich is defined in App.xaml)

But since I'm adding

it should use the styling defined in "/ResourceDictionaries/MyResources.xaml" and the background color should become green. if you remove the styling in App.xaml it will work. Adding a ResourceDictionary to ContentPage.Resources should overwrite the App.xaml styles. [ResourceDictionaryBug.zip](https://github.com/xamarin/Xamarin.Forms/files/5080591/ResourceDictionaryBug.zip)