views:

71

answers:

1

Hi, I'm using Silverlight 4 + Silverlight 4 Toolkit (April 2010). I'd like to display the dependent value of my pie chart in the chart legend. I've tried styling the legend item however I do not know how to bind to the dependent value.

Many thanks, Keith

<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>
A: 

I needed to do the same thing and found on this site, http://forums.silverlight.net/forums/p/91586/326235.aspx, that you can use the data context binding instead of the template binding.

The below applies to the section where you placed a comment

<!-- MY VALUE HERE -->

Instead of doing something like

<TextBlock Text="{Binding ActualDependentValue}" />

or

<TextBlock Text="{Binding ActualIndependentValue}" /> 

find the property that you used in the series to bind to and replace it with something like

<TextBlock
Text="{Binding PropertyNameOfIndependentOrDependentValue}"
DataContext="{Binding DataContext}"
/>
Anonymous Coward