我正在尝试从示例here开始自定义默认工具提示。
这是相关的xaml:
<ItemsControl ItemsSource="{Binding Data.Points}" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type wpf:DataPointViewModel}">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Stroke="{Binding Series.Stroke}" Fill="{Binding Series.Fill}"
Height="15" Width="15"></Rectangle>
<TextBlock Grid.Column="1" Text="{Binding ChartPoint.SeriesView.LabelPoint}"
Margin="5 0 0 0" VerticalAlignment="Center" Foreground="White"/>
<TextBlock Grid.Column="2" Text="{Binding ChartPoint.X}"
那给了我
试图获取字符串值,而不是.ToString()结果。在这种情况下,应该是“压力控制”,我似乎找不到该属性或任何示例。如何获取该值?
编辑-这是设置LabelPoint的代码:
var series = new ScatterSeries
{
MinPointShapeDiameter = 5,
MaxPointShapeDiameter = 100,
DataLabels = true,
LabelPoint = p => mg.Label // mg is a POCO, and mg.Label is "Pressure Control" for this series.
};
所以LiveCharts会以某种方式自动将LabelPoint显示为标签,我希望在工具提示中获得相同的值。