我有一个包含数据点和一些额外信息的扩展ObservableCollection
public class ExtendedCollection : ObservableCollection<KeyValuePair<string, KeyValuePair<string,int>>>
{
}
然后我还有一个ViewModel持有ColumnSeries
使用此ExtendedCollection
private ExtendedCollection columnValues = new ExtendedCollection();
public ExtendedCollection ColumnValues
{
get
{
return columnValues;
}
set
{
columnValues = value;
PropChanged("ColumnValues");
}
}
最后,我正在尝试展示收藏品&#39; Value.Key
位于每个数据点列
<chartingToolkit:ColumnSeries Name="columnSeries" DependentValuePath="Value.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=DataContext.ColumnValues.Value.Key, Mode=TwoWay}"></Label>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</chartingToolkit:ColumnSeries.DataPointStyle>
</chartingToolkit:ColumnSeries>
我为Binding
Label
尝试了很多不同的Content
,但都没有效果。如何将Content
与Value.Key
ColumnDataPoint
相关联
答案 0 :(得分:1)
ExtendedCollection
属性没有Value
属性,但该列的DataContext
包含:
<Label Grid.Row="0" Content="{Binding Value.Key}"></Label>