2009-07-17 85 views
2

我有問題將數據正確綁定到WPF圖表。當我設置的ItemsSource我得到錯誤:WPF圖表綁定錯誤

Assigned dependent axis cannot be used. The data may not be able to be rendered on the provided axis or the series may require that they axis has an origin.

oc = new ObservableCollection<Pair>(); 
heartBeats.ItemsSource = oc; 

配對我節省int和長

XAML:

... 
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" > 
<charting:Chart x:Name="ApplicatioChart"> 
      <charting:Chart.Series> 
       <charting:ColumnSeries x:Name="heartBeats" Title="Working Set" 
       DependentValueBinding="{Binding First}" IndependentValueBinding="{Binding Second}" > 

        <charting:ColumnSeries.IndependentAxis> 
         <charting:CategoryAxis Orientation="X" /> 
        </charting:ColumnSeries.IndependentAxis>      
        <charting:ColumnSeries.DependentRangeAxis> 
         <charting:LinearAxis Orientation="Y" /> 
        </charting:ColumnSeries.DependentRangeAxis> 

       </charting:ColumnSeries> 
      </charting:Chart.Series> 
     </charting:Chart> 

請幫助.. :(

+0

你似乎既結合了獨立和獨立價值「第一」? – AnthonyWJones 2009-07-17 09:30:22

回答

2

我解決這樣說:

<charting:Chart Title="Engine Performance" x:Name="ApplicationChart"> 
    <!-- Power curve --> 
    <charting:LineSeries x:Name="heartBeats" 
        Title="ManagedHeapSize"  
        IndependentValueBinding="{Binding EventTime}" 
        DependentValueBinding="{Binding ManagedHeapSize}"> 

     <!-- Vertical axis --> 
     <charting:LineSeries.DependentRangeAxis> 
      <charting:LinearAxis 
          Orientation="Y" 
          Title="ManagedHeapSize"         
          Interval="10000000" Focusable="True" 
          ShowGridLines="True"/> 
     </charting:LineSeries.DependentRangeAxis> 
    </charting:LineSeries>      

    <charting:Chart.Axes> 
     <!-- Shared horizontal axis --> 
     <charting:LinearAxis 
         Orientation="X" 
         Title="EventTime" 
         Interval="100" 
         ShowGridLines="True"/> 
    </charting:Chart.Axes> 
</charting:Chart> 
0

無法看到標記出現任何錯誤(除了相同的屬性被綁定爲依賴和獨立的值)

它似乎在Silverlight版本中工作正常,我沒有WPF版本來玩。

嘗試移除DependentRangeAxis的定義,以查看它是否使用默認值。