Button background color doesnt update only in iOS release build
I’m seeing a style switching problem that is only happening on a release build to an iOS device. The background color of buttons are not changing when the style is switched using a trigger. The TextColor is changing but not the background color. It’s strange because they are defined in the same style and it works in debug mode both on a simulator and on a physical device. Just not when deployed to a device in a release build.
For what its worth I've also noticed the background color on buttons that's are wired into the CanExecute annotations also exhibit the same behavior (text color is updated but background color isn't).
My System
Visual Studio for Mac 17.6.4 (build 472)
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.0-preview.6.8686" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.0-preview.6.8686" />
<PackageReference Include="CommunityToolkit.Maui" Version="5.2.0" />
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="2.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
My xaml page
<Button Style="{StaticResource UnSelectedListTabButton}" Text="Playlist" Command="{Binding ViewPlaylistCommand}">
<Button.Triggers>
<DataTrigger TargetType="Button" Binding="{Binding SelectedListIndex}" Value="0">
<Setter Property="Style" Value="{StaticResource SelectedListTabButton}" />
</DataTrigger>
</Button.Triggers>
</Button>
<Button Style="{StaticResource UnSelectedListTabButton}" Text="Shortlist" Command="{Binding ViewShortlistCommand}">
<Button.Triggers>
<DataTrigger TargetType="Button" Binding="{Binding SelectedListIndex}" Value="1">
<Setter Property="Style" Value="{StaticResource SelectedListTabButton}" />
</DataTrigger>
</Button.Triggers>
</Button>
Styles.xaml
<Style x:Key="ListTabButton" TargetType="Button">
<Setter Property="FontSize" Value="{OnPlatform MacCatalyst=24, Default=18}" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="BorderWidth" Value="0" />
<Setter Property="Padding" Value="{OnIdiom Phone='20,10', Default='30,10'}" />
</Style>
<Style x:Key="UnSelectedListTabButton" TargetType="Button" BasedOn="{StaticResource ListTabButton}" >
<Setter Property="TextColor" Value="White" />
<Setter Property="BackgroundColor" Value="#BF111E" />
</Style>
<Style x:Key="SelectedListTabButton" TargetType="Button" BasedOn="{StaticResource ListTabButton}" >
<Setter Property="TextColor" Value="{AppThemeBinding Light=Black, Dark=White}" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light=White, Dark=Black}" />
</Style>