我正在使用Silverlight 4 + Silverlight 4 Toolkit(2010年4月)。我想在图表图例中显示 pie 图表的相关值。我已尝试设置图例项的样式,但我不知道如何绑定到依赖值。
非常感谢, 基思
<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>
答案 0 :(得分:0)
我需要做同样的事情,并在此网站上找到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}"
/>