Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147666 | Sep 19,2019 06:47 AM UTC | Sep 20,2019 11:07 AM UTC | Xamarin.Forms | 3 |
![]() |
Tags: SfChart |
x:Class="Chart_GettingStarted.DarkTheme">
<Color x:Key="SfChartAxisLineColor">White</Color>
<Color x:Key="SfChartMajorTickLineColor">White</Color>
<Color x:Key="SfChartAxisLabelColor">White</Color>
<Color x:Key="SfChartMajorGridLineColor">White</Color>
<Color x:Key="SfChartBackgroundColor">Black</Color>
<Color x:Key="backgroundColor">Yellow</Color>
<Color x:Key="color1">Red</Color>
<Color x:Key="color2">Blue</Color>
</ResourceDictionary> |
private void Button_Clicked(object sender, EventArgs e)
{
if (isLightTheme)
{
ICollection<ResourceDictionary> mergedDictionaries = this.Resources.MergedDictionaries;
var lightTheme = mergedDictionaries.OfType<LightTheme>().FirstOrDefault();
if (lightTheme != null)
{
mergedDictionaries.Remove(lightTheme);
}
mergedDictionaries.Add(new DarkTheme());
isLightTheme = false;
}
else
{
ICollection<ResourceDictionary> mergedDictionaries = this.Resources.MergedDictionaries;
var darkTheme = mergedDictionaries.OfType<DarkTheme>().FirstOrDefault();
if (darkTheme != null)
{
mergedDictionaries.Remove(darkTheme);
}
mergedDictionaries.Add(new LightTheme());
isLightTheme = true;
}
} |
<ContentPage.Resources>
<syncTheme:SyncfusionThemeDictionary>
<syncTheme:SyncfusionThemeDictionary.MergedDictionaries>
<ResourceDictionary>
<x:String x:Key="SfChartTheme">CommonTheme</x:String>
</ResourceDictionary>
</syncTheme:SyncfusionThemeDictionary.MergedDictionaries>
</syncTheme:SyncfusionThemeDictionary>
</ContentPage.Resources>
<chart:ChartDataMarker>
<chart:ChartDataMarker.LabelTemplate>
<DataTemplate>
<StackLayout BackgroundColor="{DynamicResource backgroundColor}" >
<Label Text="High" />
</StackLayout>
</DataTemplate>
</chart:ChartDataMarker.LabelTemplate>
</chart:ChartDataMarker> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.