在饼图图例上显示相关值
问题描述:
我正在使用Silverlight 4 + Silverlight 4 Toolkit(2010年4月)。我想在图表图例中显示我的饼图图表的相关值。我已经尝试设计传说项目的样式,但是我不知道如何绑定到相关值。在饼图图例上显示相关值
非常感谢, 基思
<Style x:Key="LegendItemStyle" TargetType="toolkit:LegendItem">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:LegendItem">
<StackPanel Orientation="Horizontal">
<Rectangle Width="8" Height="8" Fill="{Binding Background}"
Stroke="{Binding BorderBrush}" StrokeThickness="1" Margin="0,0,3,0" />
<!-- MY VALUE HERE -->
<visualizationToolkit:Title Content="{TemplateBinding Content}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
答
我需要做同样的事情,发现在这个网站,http://forums.silverlight.net/forums/p/91586/326235.aspx,您可以使用数据上下文,而不是绑定模板绑定的。
以下适用于您放置评论
<!-- MY VALUE HERE -->
而是做这样的事情
<TextBlock Text="{Binding ActualDependentValue}" />
或
<TextBlock Text="{Binding ActualIndependentValue}" />
发现你在使用的属性的部分系列来绑定和取代它像
<TextBlock
Text="{Binding PropertyNameOfIndependentOrDependentValue}"
DataContext="{Binding DataContext}"
/>