2017-09-19 9 views
0

뷰 모델 DataPoint에 재산권에 ColumnDataPoint에 바인드 라벨의 내용은 그 데이터 포인트 플러스 나는이 ExtendedCollectionWPF 차트 툴킷. 내가 <code>ObservableCollection</code>을 확장 한

private ExtendedCollection columnValues = new ExtendedCollection(); 
public ExtendedCollection ColumnValues 
{ 
    get 
    { 
     return columnValues; 
    } 
    set 
    { 
     columnValues = value; 
     PropChanged("ColumnValues"); 
    } 
} 
사용하는 ColumnSeries 들고 뷰 모델이

다음
public class ExtendedCollection : ObservableCollection<KeyValuePair<string, KeyValuePair<string,int>>> 
{ 

} 

몇 가지 추가 정보를 보유

마지막으로 컬렉션 항목 '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> 

나는 LabelContent에 대해 여러 가지를 시도했지만 아무 것도 작동하지 않습니다. 어떻게 Value.KeyColumnDataPoint

답변

1

ExtendedCollection 속성이 더 Value 속성이없는의에 Content를 연결하지만 열의 DataContext이있다 할 수 있습니다

<Label Grid.Row="0" Content="{Binding Value.Key}"></Label>