0
我不确定这是否可以完成,但是我已经为DataPointStyle使用了一个自定义ControlTemplate的BubbleSeries。我想添加一些文字到泡泡,但我似乎无法获得数据绑定的工作。我想将一个TextBlock绑定到我绑定的对象中的“Name”值。希望这些代码应解释:Silverlight图表数据绑定到ControlTemplate
<Style x:Key="BubbleItemTemplate" TargetType="toolkit:BubbleDataPoint">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:BubbleDataPoint">
<Viewbox x:Name="viewbox">
<Border>
<Grid>
<TextBlock Text="{TemplateBinding Name}" />
</Grid>
</Border>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
和的ItemSource是
public void AddData(List<ChartItem> items)
{
List<Dictionary<string, object>> gridData = new List<Dictionary<string, object>>();
foreach (var i in items)
{
gridData.Add(CreateBubbleEntry(i.XAxis, i.YAxis, i.ZAxis, i.Title));
}
_bubbleView.ItemsSource = gridData;
}
private Dictionary<string, object> CreateBubbleEntry(double independent, double dependent, double size, string title)
{
var item = new Dictionary<string, object>();
item.Add("independent", independent);
item.Add("dependent", dependent);
item.Add("size", size);
item.Add("Name", title);
return item;
}
感谢