2017-09-19 10 views
0

ColumnSeries가 뷰 모델에 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, int>> 
{ 
    public string dateStamp { get; set; } 
} 

몇 가지 추가 정보를 보유 마지막으로 컬렉션의 속성 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> 

나는 LabelContent 그러나 아무도는 "DataContext.ColumnValues.dateStamp"바인딩의 경로를 변경

답변

1

시도를 작동하지 않습니다에 대한 다양한 Binding의를 시도했다 :

<Label Grid.Row="0" Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type chartingToolkit:ColumnSeries}},Path=DataContext.ColumnValues.dateStamp, Mode=TwoWay}" />