5

SilverlightチャートのLineSeriesからデータポイントマーカーを削除したいのですが。Webで見つけた唯一の方法は、VisibilityPropertyをCollapseに設定することです。

//現在のSLツールキットリリースでは機能しませんvarcollapseDataPointSetter= new Setter(Control.VisibilityProperty、Visibility.Collapsed);

ただし、これはSLツールキットの現在のリリースでは機能しません。現在のリリースでDataPointマーカーを削除または非表示にするにはどうすればよいですか?

4

4 に答える 4

10

パンタルヘイ、

次のグラフ スタイルを (参照テ​​ンプレートと共に) 使用して、データ ポイントを非表示にします。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>
于 2010-02-05T17:11:35.513 に答える
4

私の意見では、スタイルを使用してそれを行うことは最善のアプローチではありません。株価チャートのように多くのデータポイントがある場合でも、膨大な量のビジュアルが残っているからです。

public class LineSeriesEx : LineSeries
{
    protected override DataPoint CreateDataPoint()
    {
        return new EmptyDataPoint();
    }
}

public class EmptyDataPoint : DataPoint
{
    // As the method name says, this DataPoint is empty.
}

このようにすると、スタイルを設定した場合に比べてビジュアルがほぼ 5 分の 1 になります。

于 2012-07-06T08:10:53.863 に答える
3

私は Jim のソリューションを使用し (ちなみに、大変お世話になりました)、それをデフォルトのグラフ テンプレートに適用しました。

パレット領域には、シリーズの各行のリソース ディクショナリがあります。

Jim のコントロール テンプレートを使用してそれを取り除くことができた方法を次に示します。各 ResourceDictonary に配置できるため、1 行ずつ行う必要はありません。

<toolkit:ResourceDictionaryCollection>
<ResourceDictionary>
<!-- I wanted a solid color brush so I just went ahead and defined it in the palette-->
<SolidColorBrush x:Key="Background" Color="Green"/>
<Style x:Key="DataPointStyle" TargetType="Control">
<Setter Property="Background" Value="{StaticResource Background}"/>
<!-- below is where I entered Jim's control template into the default palette defined-->
<Setter Property="Template">
<ControlTemplate TargetType="charting:LineDataPoint">
<Grid x:Name="Root" Opacity="1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</toolkit:ResourceDictionaryCollection>

これは少なくとも私にとってはうまくいき、多くの時間を節約できます(そして、抜く前にすでに多くの髪を節約しています)

于 2012-10-11T15:57:51.837 に答える
1
<charting:LineSeries.DataPointStyle>
                            <Style TargetType="charting:LineDataPoint">
                                <Setter Property="Visibility" Value="Collapsed"/>
                                <Setter Property="Background" Value="violet"/>
                                <Setter Property="Opacity" Value="0" />
                            </Style>
                        </charting:LineSeries.DataPointStyle>

于 2011-11-07T11:45:56.427 に答える