Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change the background of AreaSeries in WPF
    text
    copied!<p>I'm having a strange problem with chartingToolkit:AreaSeries in WPF:</p> <p>Here's the code I'm using to construct the chart:</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit" x:Class="leartWPF.ButtonTest" x:Name="Window" Title="ButtonTest" Width="640" Height="480"&gt; &lt;Grid x:Name="LayoutRoot"&gt; &lt;chartingToolkit:Chart Margin="56,91,50,72" Title="Chart Title" DataContext="{Binding ElementName=Window, Mode=OneWay}"&gt; &lt;chartingToolkit:Chart.Template&gt; &lt;ControlTemplate TargetType="{x:Type chartingToolkit:Chart}"&gt; &lt;Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"&gt; &lt;Grid&gt; &lt;chartingprimitives:EdgePanel Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" Grid.Row="1" Margin="0"&gt; &lt;Grid Panel.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" /&gt; &lt;Border Panel.ZIndex="10" BorderBrush="#FF919191" BorderThickness="1" /&gt; &lt;/chartingprimitives:EdgePanel&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/chartingToolkit:Chart.Template&gt; &lt;chartingToolkit:LineSeries ItemsSource="{Binding Path=Data}" IndependentValuePath="Date" DependentValuePath="Value"/&gt; &lt;chartingToolkit:AreaSeries ItemsSource="{Binding Path=Data}" IndependentValueBinding="{Binding Date}" DependentValueBinding="{Binding Value}"&gt; &lt;chartingToolkit:AreaSeries.Background&gt; &lt;RadialGradientBrush Center="0.075,0.015" GradientOrigin="-0.1,-0.1" RadiusY="0.9" RadiusX="1.05"&gt; &lt;GradientStop Color="#FFB5D2ED" Offset="1"/&gt; &lt;GradientStop Color="#FF1E4C78"/&gt; &lt;/RadialGradientBrush&gt; &lt;/chartingToolkit:AreaSeries.Background&gt; &lt;/chartingToolkit:AreaSeries&gt; &lt;/chartingToolkit:Chart&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Both #FFB5D2EDand #FF1E4C78 are blue colors.</p> <p><img src="https://i.stack.imgur.com/KSL1S.png" alt="Both #FFB5D2EDand #FF1E4C78are blue colors"></p> <p>Here's what the actual chart looks like:</p> <p><img src="https://i.stack.imgur.com/hqKcK.png" alt="chart of the wrong color"></p> <p>Why am I getting this, and how do I change the color?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload