2010-02-12 2 views
1

Silverlight 3 툴킷 차트는 정말 멋지다. 나는 BarSeries를 사용하고 실버 라이트는 바운드 값에 비례하여 막대의 길이를 보여줍니다. 그러나 술집에서 또는 술집 바로 옆에있는 실제 가치를 얻는 방법이 있습니까? 여기 내 XAML입니다Silverlight 3 Toolkit Charting : 막대에 값을 표시하는 방법?

<chartingToolkit:Chart 
         Grid.Column="1" 
         x:Name="chartEnvironmentStatusGlobal" 
         Title="Environment Status"> 
         <chartingToolkit:BarSeries 
          x:Name="chartEnvironmentStatus" 
          Title="Pass" 
          HorizontalAlignment="Stretch" 
          VerticalAlignment="Stretch" 
          Background="Green" 
          IndependentValueBinding="{Binding Path=Instance}" 
          DependentValueBinding="{Binding Path=Count}" 
          AnimationSequence="LastToFirst"> 
          </chartingToolkit:BarSeries> 
         <chartingToolkit:BarSeries 
          x:Name="chartEnvironmentStatus1" 
          Title="Fail" 
          HorizontalAlignment="Stretch" 
          VerticalAlignment="Stretch" 
          Background="Red" 
          IndependentValueBinding="{Binding Path=Instance}" 
          DependentValueBinding="{Binding Path=Count}" 
          AnimationSequence="LastToFirst"> 
          </chartingToolkit:BarSeries> 
        </chartingToolkit:Chart> 

감사합니다.

답변

2

BarDataPoint에 대한 새 템플릿을 만들어야합니다. 나는 전체 템플릿을 여기에 게시하지 않을 것이다. 왜냐하면 a) 그것의 상당히 크고 b) 나는 어디에서 저작권을 유지하고 있는지 확실하지 않기 때문이다.

블렌드하면 툴을 사용하여 복사본을 만들 수 있어야 기존 템플릿을 쉽게 얻을 수 있습니다.

<Style x:Key="BarDataPointWithContent" TargetType="charting:BarDataPoint"> 
    <Setter Property="Template"> 
    <Setter.Value> 
     <Border ... copy from original template... > 
     <!-- Wads of original VisualStateManager stuff here --> 
     <Grid Background="{TemplateBinding Background}"> 
      <!-- Original set of Rectangles and Border here --> 
      <TextBlock Text="{TemplateBinding FormattedDependentValue}" 
      HorizontalAlignment="Center" /> 
     </Grid> 
     <ToolTipService.ToolTip> 
      <!-- Do something different here perhaps --> 
     </ToolTipService.ToolTip> 
     </Border> 
    </Setter.Value> 
    </Setter> 
</Style> 

기본적으로 내가 무슨 짓을했는지하는 것은 최종 TextBlock 것을 추가하고 바인딩 - :

#someSourceCodeRootFolder\Controls.DataVisualization.Toolkit\Charting\DataPoint\BarDataPoint.xaml 

리소스 사전에이를 만들 -이 : 또는 소스 코드에서 그것을 얻을 수의 발견 도구 설명에서 해당 ContentControl에 사용하는 속성과 동일한 FormattedDependentValue 속성으로 변경합니다. TextBlock에 원하는 스타일을 추가하기 위해 스타일을 추가 할 수 있습니다. 도구 팁 내용을 통해 다른 작업을 수행 할 수도 있습니다.

당신에 대해 교수형이 스타일은 차트 자체에서이 작업을 수행 할 수 있습니다 그래서 함께 - 당신이 어딘가에 문서 템플릿을 추가시겠습니까 숨어 MSofties

<chartingToolkit:BarSeries.DataPointStyle> 
    <Style TargetType="BarDataPoint" BasedOn="{StaticResouce BarDataPointWithContent}" > 
    <Setter Property="Background" Value="Red" /> 
    </Style> 
</chartingToolkit:BarSeries.DataPointStyle> 

주 그래서 우리 그들을 추출하려면 소스 코드, 혼합 또는 반사판이 필요하지 않습니까?

+0

매력적이었습니다! 고맙습니다. Silverlight 템플릿 작성은 멋지다. – funwithcoding

+0

시도해 볼 수 있습니다. http://blogs.msdn.com/delay/archive/2008/12/14/expanded-access-to-silverlight-2-s-generic-xaml-resources-silverlightdefaultstylebrowser-updated-for -better-compatibility.aspx를 사용하여 템플릿 추출 – Jags

관련 문제