We have analysed reported query. Based on this we have prepared a sample and change the theme dynamically. Please have a link from below.
Code snippet:
[XAML]
|
<ContentPage.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<syncTheme:LightTheme />
<buttons:SfButtonStyles />
<syncfusion:SfNumericTextBoxStyles/>
<textInput:SfTextInputLayoutStyles/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout Margin="20" VerticalOptions="CenterAndExpand">
<textinputlayout:SfTextInputLayout>
<syncfusion:SfNumericTextBox Value="123.45" />
</textinputlayout:SfTextInputLayout>
<Button Text="Light" x:Name="button" Clicked="Button_Clicked"
HorizontalOptions="Center"
VerticalOptions="Center" />
</StackLayout> |
[C#]
|
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.Remove(lightTheme);
}
mergedDictionaries.Add(new DarkTheme());
button.Text = "Dark";
}
else
{
var darkTheme = mergedDictionaries.OfType<DarkTheme>().FirstOrDefault();
if (darkTheme != null)
{
mergedDictionaries.Remove(darkTheme);
}
mergedDictionaries.Add(new LightTheme());
button.Text = "Light";
}
} |
Please check with the sample and if the issue still persists please modify the same with the issue reproducing steps and also mention in which scenario you could reproduce the issue which will be helpful for us to analyse further and provide an appropriate solution.
Regards,
Sridevi S.