Articles in this section
Category / Section

How to get the dynamic theme change effect in numeric control inside the Xamarin.Forms text input layout (SfTextInputLayout)?

1 min read

This article explains how to dynamically change the theme when having a UI contains the  Syncfusion Xamarin Forms NumericTextBox inside the SfTextInputLayour as follows.


dynamic theme effect


In case of requirement to have a specific control’s theme effect, add the SfNumericTextBoxStyles and SfTextInputLayoutStyles by following the provided guidelines in this link.



                <syncTheme:LightTheme />
                <buttons:SfButtonStyles />
    <StackLayout Margin="20" VerticalOptions="CenterAndExpand">
            <syncfusion:SfNumericTextBox  Value="123.45" />
        <Button  Text="Light" x:Name="button" Clicked="Button_Clicked"   
                 VerticalOptions="Center" />


On the button click, remove the previously added theme and add a new required theme to the merged dictionaries as follows.



        private void Button_Clicked(object sender, EventArgs e)
            ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries;
            if (button.Text == "Light")
                var lightTheme = mergedDictionaries.OfType<LightTheme>().FirstOrDefault();
                if (lightTheme != null)
                mergedDictionaries.Add(new DarkTheme());
                button.Text = "Dark";
                var darkTheme = mergedDictionaries.OfType<DarkTheme>().FirstOrDefault();
                if (darkTheme != null)
                mergedDictionaries.Add(new LightTheme());
                button.Text = "Light";



View the sample in GitHub.

See also

How to set a custom background, text, and border colors for the SfNumericTextBox

How to customize the font style of SfNumericTextBox

Localization in Xamarin Numeric Entry (SfNumericTextBox)

Number Formatting in Xamarin Numeric Entry (SfNumericTextBox)

Return Type in Xamarin Numeric Entry (SfNumericTextBox)



Hope you enjoyed learning about How to get the dynamic theme change effect in numeric control inside the Xamarin.Forms text input layout (SfTextInputLayout).

You can refer to our Xamarin.Forms feature tour page to learn about its other groundbreaking feature representations. You can explore our Xamarin.Forms documentation to understand how to present and manipulate data.

For current customers, you can check out our Angular components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our Angular Diagram and other Angular components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!



Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment