0
我有一個擴展ObservableCollection
保存的數據點加上一些額外的信息WPF圖表工具包。綁定標籤在ColumnDataPoint內容的ColumnSeries視圖模型
public class ExtendedCollection : ObservableCollection<KeyValuePair<string, int>>
{
public string dateStamp { get; set; }
}
然後我也有一個ViewModel持有使用該ExtendedCollection
private ExtendedCollection columnValues = new ExtendedCollection();
public ExtendedCollection ColumnValues
{
get
{
return columnValues;
}
set
{
columnValues = value;
PropChanged("ColumnValues");
}
}
的ColumnSeries
最後,我試圖在模板中的每個數據點的列中顯示集合的屬性dateStamp
<chartingToolkit:ColumnSeries Name="columnSeries" DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding ColumnValues}">
<chartingToolkit:ColumnSeries.DataPointStyle>
<Style TargetType="chartingToolkit:ColumnDataPoint">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:ColumnDataPoint">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type chartingToolkit:ColumnSeries}},Path=dateStamp, Mode=TwoWay}"></Label>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</chartingToolkit:ColumnSeries.DataPointStyle>
</chartingToolkit:ColumnSeries>
我已經嘗試了很多不同的Binding
S爲Label
的Content
但沒有工作