A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello @Jai Holloway ,
Thanks for your question.
I recommend some following steps:
- Replace
DynamicResourcewithStaticResourceinsideAppThemeBinding.
In MainPage.xaml, change every occurrence of DynamicResource inside AppThemeBinding:
You can refer to these following code examples:
Replace this:
Style="{AppThemeBinding Light={DynamicResource ContentPageBase}, Dark={DynamicResource ContentPageBaseDark}}"
Style="{AppThemeBinding Light={DynamicResource BusyIndicator}, Dark={DynamicResource BusyIndicatorDark}}"
Style="{AppThemeBinding Light={DynamicResource ListViewDetail}, Dark={DynamicResource ListViewDetailDark}}"
Style="{AppThemeBinding Light={DynamicResource RadBusyIndicatorGlobal}, Dark={DynamicResource RadBusyIndicatorGlobalDark}}"
BackgroundColor="{AppThemeBinding Light={DynamicResource TabViewBackgroundColor}, Dark={DynamicResource TabViewBackgroundColorDark}}"
Style="{AppThemeBinding Light={DynamicResource SortPickerControlStyle}, Dark={DynamicResource SortPickerControlStyleDark}}"
BackgroundColor="{AppThemeBinding Light={DynamicResource TableViewBase}, Dark={DynamicResource TableViewBaseDark}}"
BackgroundColor="{AppThemeBinding Light={DynamicResource TabViewBackgroundColor}, Dark={DynamicResource TabViewBackgroundColorDark}}"
With this:
Style="{AppThemeBinding Light={StaticResource ContentPageBase}, Dark={StaticResource ContentPageBaseDark}}"
Style="{AppThemeBinding Light={StaticResource BusyIndicator}, Dark={StaticResource BusyIndicatorDark}}"
Style="{AppThemeBinding Light={StaticResource ListViewDetail}, Dark={StaticResource ListViewDetailDark}}"
Style="{AppThemeBinding Light={StaticResource RadBusyIndicatorGlobal}, Dark={StaticResource RadBusyIndicatorGlobalDark}}"
BackgroundColor="{AppThemeBinding Light={StaticResource TabViewBackgroundColor}, Dark={StaticResource TabViewBackgroundColorDark}}"
Style="{AppThemeBinding Light={StaticResource SortPickerControlStyle}, Dark={StaticResource SortPickerControlStyleDark}}"
BackgroundColor="{AppThemeBinding Light={StaticResource TableViewBase}, Dark={StaticResource TableViewBaseDark}}"
BackgroundColor="{AppThemeBinding Light={StaticResource TabViewBackgroundColor}, Dark={StaticResource TabViewBackgroundColorDark}}"
- Fix the inconsistent mix of
DynamicResourceandStaticResource.
Both Light= and Dark= sides must use the same resource type.
In MainPage.xaml, change this line:
Style="{AppThemeBinding Light={DynamicResource TableViewBase}, Dark={StaticResource TableViewBaseDark}}"
To:
Style="{AppThemeBinding Light={StaticResource TableViewBase}, Dark={StaticResource TableViewBaseDark}}"
- Remove
Source=fromResourceDictionarythat hasx:Class=.
In DarkMode.xaml, you should not use Source= and x:Class= on the same element.
Change this:
<ResourceDictionary
x:Class="TourGrosses.Styles.DarkMode"
Source="DefaultTheme.xaml">
To:
<ResourceDictionary
x:Class="TourGrosses.Styles.DarkMode">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DefaultTheme.xaml"/>
</ResourceDictionary.MergedDictionaries>
- Add
AppThemeBindinginside custom controls.
Your dark styles for custom controls are defined in DarkMode.xaml but never connected to the actual controls. Open each custom control XAML and apply AppThemeBinding to each Label:
For ex: in ArtistSummaryItem.xaml:
<Label Text="{Binding Artist}"
Style="{AppThemeBinding
Light={StaticResource ArtistSummaryLabel},
Dark={StaticResource ArtistSummaryLabelDark}}"/>
I tested by creating a simple project and it works as expected.
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.