Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

silverlight - Removing (collapsing) DataPoints in a LineSeries?

I'd like to remove the datapoint markers from a LineSeries in my Silverlight chart. The only way i found on the web is to set the VisibilityProperty to Collapse.

//not working in the current SL toolkit release var collapseDataPointSetter = new Setter(Control.VisibilityProperty, Visibility.Collapsed);

But this isn't working for the current release of the SL toolkit. How can i remove or hide DataPoint Markers in the current release?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

pantarhei,

Use the following chart styles (with referenced templates) to hide the data points. I have included styles for both the LineSeries and the AreaSeries.

Good luck, Jim

<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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...