2011-02-11 14 views
2

上のデータポイントのseleted値を読み取るためにどのように私は次のようにSilverlightのtookitを使用してバブルチャートを作成しました:Silverlightのツールキット:バブルチャート

<charting:Chart Title="Bubble Chart" 
      LegendTitle="Legend" 
      Name="chart1" Margin="0,0,0,42" 
      HorizontalAlignment="Left" Width="568"> 
<charting:Chart.Series> 
     <charting:BubbleSeries Title="Pollutant A" IsSelectionEnabled="True" 
            ItemsSource="{Binding Pollution}" 
            IndependentValuePath="AQI" 
            DependentValuePath="Level" 
            SelectionChanged="ChangeSomething" 
            SizeValuePath="size1" > 


      </charting:BubbleSeries> 

    </charting:Chart> 

そして、私のxaml.csは次のようにハンドラを定義しています

private void ChangeSomething(object sender, SelectionChangedEventArgs e){ 

     Text1.text="selection changed" 
     // Here I want to show the value of the bubble selected 

}

誰かがそれを行う方法を教えてくださいことはできますか?ありがとう:)

答えて

1

AddedItemsというパラメータがあります。これは、この変更中に選択したアイテムに追加されたItemsSourceのアイテムのリストです。ほとんどの場合、選択されたばかりのアイテムは1つしかありません。

例では、モデルのPollutionプロパティから返されたオブジェクトの型名をイベントとして扱います。タイプ名はPollutionSampleです(もちろん私はここで推測しています)。

ですから、このような選択PollutionSampleアクセスします - それは働いた

private void ChangeSomething(object sender, SelectionChangedEventArgs e) 
{ 
    if (e.AddedItems.Count > 0) 
    { 
     PollutionSample ps = e.AddedItems[0] as PollutionSample; 
     if (ps != null) 
     { 
       // Do something with sample 
     } 
    } 
} 
+0

を!どうもありがとう :) :) – atv

関連する問題