2010-06-12 32 views
2

我正在使用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> 

回答

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}" 
/> 
相關問題