pantarhei,
使用下面的圖表樣式(含參照的模板)隱藏的數據點。我已經包含LineSeries和AreaSeries的樣式。
祝你好運,吉姆
<ControlTemplate x:Key="CommonAreaSeriesDataPointTemplate" TargetType="charting:AreaDataPoint">
<!--Comment out data points from the default template; just an empty template-->
<Grid x:Name="Root" Opacity="1">
<!--<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<ContentControl Content="{TemplateBinding FormattedDependentValue}" />
<ContentControl Content="{TemplateBinding FormattedIndependentValue}" />
</StackPanel>
</ToolTipService.ToolTip>
<Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" />-->
</Grid>
</ControlTemplate>
<Style x:Key="CommonAreaSeriesDataPoint" TargetType="charting:AreaDataPoint">
<Setter Property="Background" Value="{StaticResource CommonAreaSeriesBackground}" />
<Setter Property="Template" Value="{StaticResource CommonAreaSeriesDataPointTemplate}" />
</Style>
<Style x:Key="CommonAreaSeriesPath" TargetType="Path">
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="Stroke" Value="DarkGray" />
<Setter Property="Effect" Value="{StaticResource DialogDropShadow}" />
</Style>
<ControlTemplate x:Key="CommonLineSeriesDataPointTemplate" TargetType="charting:LineDataPoint">
<!--Comment out data points from the default template; just an empty template-->
<Grid x:Name="Root" Opacity="1">
<!--<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<ContentControl Content="{TemplateBinding FormattedDependentValue}" />
<ContentControl Content="{TemplateBinding FormattedIndependentValue}" />-->
<!--Example of how to access the bound business object-->
<!--<ContentControl Content="{Binding Amount}" DataContext="{TemplateBinding DataContext}" />-->
<!--</StackPanel>
</ToolTipService.ToolTip>-->
<!--<Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" />-->
</Grid>
</ControlTemplate>
<Style x:Key="CommonLineSeriesDataPoint" TargetType="charting:LineDataPoint">
<Setter Property="IndependentValueStringFormat" Value="{}{0:yyyy}" />
<Setter Property="DependentValueStringFormat" Value="{}{0:c0}" />
<Setter Property="Background" Value="#FF0077CC" />
<Setter Property="BorderBrush" Value="White" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template" Value="{StaticResource CommonLineSeriesDataPointTemplate}" />
</Style>
<Style x:Key="CommonLineSeriesPolyline" TargetType="Polyline">
<Setter Property="StrokeThickness" Value="5" />
<Setter Property="Effect" Value="{StaticResource DialogDropShadow}" />
</Style>
<!-- Implicit non-Key'd Styles BasedOn Common Explicit Key'd Styles above -->
<Style TargetType="charting:AreaSeries">
<Setter Property="DataPointStyle" Value="{StaticResource CommonAreaSeriesDataPoint}" />
<Setter Property="PathStyle" Value="{StaticResource CommonAreaSeriesPath}" />
</Style>
<Style TargetType="charting:LineSeries">
<Setter Property="DataPointStyle" Value="{StaticResource CommonLineSeriesDataPoint}" />
<Setter Property="PolylineStyle" Value="{StaticResource CommonLineSeriesPolyline}" />
</Style>
謝謝。將嘗試它。但似乎是我在找什麼。 – pantarhei 2010-02-11 07:05:07
像WPF中的魅力一樣工作...非常感謝。 – sprite 2010-08-31 08:58:23
非常感謝上面的代碼@Jim。儘管如此,我仍然錯過了這種方法,LineSeries中的線條顏色將固定到圖表中所有系列的LineDataPoint樣式中設置的背景值。移除背景設置器也無濟於事,它只是一種不同的修復顏色。採用上述方法,線條顏色對於不同線條系列是否有自動變化的方法? – 2011-11-23 10:56:06