2013-06-14 2 views
0

내 xaml에서 전체 차트를 바인딩하는 방법을 찾고 있습니다. 한 시리즈뿐만 아니라 전체 차트. 차트에 여러 시리즈를 동적으로 추가해야하기 때문입니다.전체 차트를 프런트 엔드에 바인딩 할 수 없습니다.

XAML :

<chart:Chart DataContext="{Binding Path=FocusEnergyChart, UpdateSourceTrigger=PropertyChanged}"/> 

C 번호 :

public void DrawChart() 
    { 
     myChart = new Chart(); 

     LinearAxis xAxis = new LinearAxis(); 
     xAxis.Orientation = AxisOrientation.X; 
     xAxis.Title = "Energy"; 
     LinearAxis yAxis = new LinearAxis(); 
     yAxis.Orientation = AxisOrientation.Y; 
     yAxis.Title = "Focus"; 
     myChart.Axes.Add(xAxis); 
     myChart.Axes.Add(yAxis); 
     myChart.Title = "Focus Energy - Chart"; 
     foreach(string aKey in myGraphData.Keys) 
     { 
      BubbleSeries aSeries = new BubbleSeries(); 
      aSeries.Title = aKey; 
      aSeries.ItemsSource = myGraphData[aKey]; 
      aSeries.DependentValuePath = "Focus"; 
      aSeries.IndependentValuePath = "Energy"; 
      aSeries.SizeValuePath = "Size"; 
      aSeries.SetResourceReference(Series.BackgroundProperty, "Background"); 
      aSeries.SetResourceReference(BubbleSeries.LegendItemStyleProperty, "CustomLegendItemStyle"); 
      aSeries.SetResourceReference(BubbleSeries.DataPointStyleProperty, "BubbleToolTipTemplate"); 
      myChart.Series.Add(aSeries); 
     } 
     base.OnPropertyChanged("FocusEnergyChart"); 
    } 

    public Chart FocusEnergyChart 
    { 
     get { return myChart; } 
    } 

난 그냥 나에게 빈 ChartArea를 보여이 코드를 실행하려고.

누군가 나를 도울 수 있기를 바랍니다.

감사합니다.

답변

0

XAML에서 선언 한 차트의 DataContext으로 다른 차트를 추가하기 만하면됩니다.

당신은 ContentControl을 사용하고 코드 숨김에서 만든 차트 콘텐츠의 바인딩 할 수 있습니다 :

<ContentControl Content="{Binding Path=FocusEnergyChart}" /> 
+0

감사합니다 많이! 작동 중! – alexstdev