Question

Silverlight 3 cartographie boîte à outils est génial. J'utilise BarSeries et silverlight montre la longueur de la barre proportionnelle à la valeur limite. Mais est-il possible d'obtenir la valeur réelle sur la barre ou juste à côté du bar? Voici mon XAML

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

Je vous remercie à l'avance.

Était-ce utile?

La solution

Vous devez créer un nouveau modèle pour la BarDataPoint. Je ne vais pas poster ici tout le modèle parce que a) son assez grand et b) Je ne sais pas où je suis sur le droit d'auteur.

Vous pouvez obtenir le modèle existant assez facilement si vous avez mélanger, vous devriez être en mesure de créer une copie avec l'outil. Sinon, vous pouvez l'obtenir à partir du code source de son présent dans: -

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

Dans un dictionnaire de ressources créer ceci: -

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

En fait ce que je l'ai fait est ajouté que TextBlock finale et lié à la même propriété que FormattedDependentValue l'info-bulle utilise dans son ContentControl. Vous pouvez ajouter plus de style à la TextBlock pour obtenir l'apparence que vous voulez, vous pouvez aussi faire quelque chose de différent avec le contenu de la pointe de l'outil.

Donc, avec ce style traîner, vous pouvez le faire dans le tableau lui-même: -

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

Note à MSofties tapies

Pouvez-vous s'il vous plaît ajouter les modèles à la documentation quelque part afin que nous ne avons pas besoin du code source, mélange ou réflecteur pour les extraire?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top