2013-04-09 19 views
0

我有以下圖表:WPF工具包圖表 - 自定義工具提示 - 顯示出複雜的依賴值

<cht:Chart ...> 
    <cht:Chart.Series> 
     <cht:LineSeries Name="LineSeries" Title="a" 
      DependentValueBinding="{Binding Path=Value}" 
      IndependentValueBinding="{Binding Path=Key}" 
      ItemsSource="{Binding Path=SourceCollection}" 
      IsSelectionEnabled="True" 
      DataPointStyle="{DynamicResource SmallPointStyle}"> 
     </cht:LineSeries> 
    </cht:Chart.Series> 
</cht:Chart> 

而且DataPointStyle:

<Style TargetType="cht:LineDataPoint"> 
    <Setter Property="Width" Value="2" /> 
    <Setter Property="Height" Value="2" /> 
    <Setter Property="DependentValueStringFormat" Value="{}{0:0.00}"/> 
</Style> 
<Style x:Key="SmallPointStyle" TargetType="cht:LineDataPoint" BasedOn="{StaticResource {x:Type cht:LineDataPoint}}"> 
    <Setter Property="BorderBrush" Value="Orange"/> 
    <Setter Property="Background" Value="Orange"/> 
</Style> 

的源集合是KeyValuePair列表。 該應用程序正常工作。

我遇到了一個問題,因爲我想使用KeyValuePair>的集合,其中doubleA是提取的數據,doubleB是doubleA的標準化值,基於範圍。所以我需要改變檢測LineSeries是:

<cht:Chart ...> 
    <cht:Chart.Series> 
     <cht:LineSeries Name="LineSeries" Title="a" 
     DependentValueBinding="{Binding Path=Value.Value}" 
     IndependentValueBinding="{Binding Path=Key}" 
     ItemsSource="{Binding Path=SourceCollection}" 
     IsSelectionEnabled="True" 
     DataPointStyle="{DynamicResource SmallPointStyle}"> 
     </cht:LineSeries> 
    </cht:Chart.Series> 
</cht:Chart> 

它的工作原理如我所料,但我需要在工具提示中真正的價值(Value.Key),而不是DependentValue顯現。無論如何要做到這一點?

回答

0

看到這個blog post爲一個可能的解決方案。

您會發現必須覆蓋的LineSeries數據點樣式here。 但是,請記住,當您覆蓋模板時,您將不會再獲得任何隨機顏色。

祝你好運!