Wpf wfp图表工具包:在所有列上方显示数据点值

Wpf wfp图表工具包:在所有列上方显示数据点值,wpf,charts,Wpf,Charts,这里完全是紧急情况。刚刚第一次看到WPF,需要这个快速,所以请原谅我:如果我第一次没有提供足够的信息,我保证编辑这个问题 在使用命名空间定义的图表对象中: xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" 我正在画一个简单的条形图 <charting:Char

这里完全是紧急情况。刚刚第一次看到WPF,需要这个快速,所以请原谅我:如果我第一次没有提供足够的信息,我保证编辑这个问题

在使用命名空间定义的图表对象中:

xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
我正在画一个简单的条形图

<charting:Chart Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" 
                       Visibility="{Binding Path=MyCurrentResultsView, Converter={StaticResource ResourceKey=NullObjectToVisibilityConverter}}"
                       Background="Transparent" Foreground="White"
                       Margin="50,0,50,0" Height="350"
                       HorizontalAlignment="Stretch" Title="{Binding Path=MyCurrentResultsView.Name}">
    <charting:ColumnSeries Height="350" Foreground="Black"
                        ItemsSource="{Binding Path=MyCurrentResultsView.ResultsView}"
                        IndependentValueBinding="{Binding Key}"
                        DependentValueBinding="{Binding Value}">
    </charting:ColumnSeries>
</charting:Chart>

我想做的是在列上方显示每列的值(如果可能的话,甚至在列矩形内部显示:这些是百分比值,目的是使它们在条形图上更可见)

我一直在查看样式信息,但这里不仅仅是样式。我认为有两种可能性。要么:

  • 对于系列中的每个列项目,定义一个变换,该变换将框架定位在每个列上方,创建一个标签设置为从属值的文本框,然后在框架内绘制文本框
  • 在“ColumnSeries”或“ColumnItem?”上查找某种类型的属性,该属性“启用”列上方绑定值的显示

  • 这里完全是在黑暗中拍摄的。谢谢。

    我会尝试更改
    ColumnDatapointTemplate
    如下:

    <charting:ColumnSeries Height="350" Foreground="Black"
                            ItemsSource="{Binding Path=MyCurrentResultsView.ResultsView}"
                            IndependentValueBinding="{Binding Key}"
                            DependentValueBinding="{Binding Value}">
        <charting:ColumnSeries.DataPointStyle>
            <Style TargetType="charting:ColumnDataPoint">
                <Setter Property="Template">
                    <Setter.Value>
                     <ControlTemplate TargetType="charting:ColumnDataPoint">
                     <Grid>
                        <Rectangle Fill="{TemplateBinding Background}" Stroke="Black"/>
                        <Grid Margin="0 -20 0 0" HorizontalAlignment="Center" VerticalAlignment="Top">
                            <TextBlock Text="{TemplateBinding FormattedDependentValue}" Margin="2"/>
                        </Grid>
                     </Grid>
                     </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </charting:ColumnSeries.DataPointStyle> 
    </charting:ColumnSeries>
    
    
    
    玩一点垂直对齐和/或边距,您将能够在列和其他栏中获得信息


    希望这有帮助

    这太完美了!我发现很多文档指向不同的方向,但不是画标签的确切方式。这正是我需要的。