SfTextInputLayout HintLabelStyle doesn't respond to change in AppTheme

Hi,

On the SfTextInputLayout, the HintLabel style doesn't respond to setting the UserAppTheme but rather always inherits the devices Light or Dark mode setting.


I've defined my style 

 <Setter Property="HintLabelStyle">

               <sfcore:LabelStyle

                    FontFamily="PoppinsRegular"

                    TextColor="{AppThemeBinding Light={StaticResource ColourBlack-2}, Dark={StaticResource ColourWhiteSmoke}}"

                    FontSize="10">

            </sfcore:LabelStyle>

        </Setter>


In my app I've setup a Light and Dark App Theme and allow the user to change it regardless of the device setting which the app then reacts to by using the Dark or Light styles.  The HintLabelStyle doesn't react to the change though but always uses the devices mode which ends up with a the ColourWhiteSmoke being used even when the user changes the UserAppTheme to Light so is unreadable against a light background.  The rest of the control responds accordingly though.  Is this a known issue?  It exists on both Android and iOS.


Regards

Shaun



1 Reply

HC Hariharan Chokkalingam Syncfusion Team October 14, 2024 12:52 PM UTC

Hi Shaun,

 

Thank you for reaching out and providing detailed information about your query. We would like to inform you that the issue is related to the DynamicResource style not being applied to inner views of the frame work control. We have already logged a bug report with the .NET MAUI framework team and have updated the existing issue link accordingly. We will keep you informed as soon as we receive any updates from the framework team.

 

GitHub Link : Issue with the usage of DynamicResource for inner views of a custom control

 

As a workaround, we suggest using DynamicResource for the LabelStyle property. You can set the color in the LabelStyle and then use that key for your HintLabelStyle at the sample level. We've updated your sample based on this approach, which we've attached for your reference. Please review the sample and let us know if you need any additional information.

 

Below is a code snippet illustrating this approach:

  <ContentPage.Resources>

<syncfusion:LabelStyle x:Key="lightTheme" TextColor="Red"/>

  <syncfusion:LabelStyle x:Key="darkTheme" TextColor="Yellow"/>

 

  <Style TargetType="syncfusion:SfTextInputLayout">

      <Setter Property="HintLabelStyle" Value="{AppThemeBinding Light={DynamicResource lightTheme}, Dark={DynamicResource darkTheme}}"/>

  </Style>

</ContentPage.Resources>


 

Please let us know whether the provided suggestion helps to resolve your query. Please don’t hesitate to contact us if you have any concerns or queries.

 

Regards,

Hariharan.


Attachment: TextInputLayoutMaui_7952505c.zip

Loader.
Up arrow icon