I have a chart and I want to have the item highlighting such that not only the point bars, but also the axis labels, change appearance when the point is highlighted.
The way I've done it is as follows:
-----------------------------------------------------
Private Sub chtTest_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles chtTest.DataBound For i As Integer = 1 To chtTest.Data.X.Count
Dim sec As New ChartFX.WPF.AxisSection()
sec.From = CType(i, ChartFX.WPF.DataUnit)
sec.To = CType(i, ChartFX.WPF.DataUnit)
chtTest.AxisX.Sections.Add(sec)
Next
End Sub Private lastPoint As Integer = -1
Private Sub chtTest_Highlighting(ByVal sender As Object, ByVal args As ChartFX.WPF.HighlightingEventArgs) Handles chtTest.Highlighting
Dim point As Integer = CType(args.Object, ChartFX.WPF.SeriesPoint).Point
If args.Highlighting Then
chtTest.AxisX.Sections(point).Foreground = Windows.Media.Brushes.Red
chtTest.AxisX.Sections(point).FontWeight = FontWeights.Bold
If (lastPoint >= 0) And (point <> lastPoint) Then
chtTest.AxisX.Sections(lastPoint).Foreground = Windows.Media.Brushes.Black
chtTest.AxisX.Sections(point).FontWeight = FontWeights.Normal
End If
lastPoint = point
Else
chtTest.AxisX.Sections(point).Foreground = Windows.Media.Brushes.Black
chtTest.AxisX.Sections(point).FontWeight = FontWeights.Normal
End If
End Sub
-----------------------------------------------------
This works for the most part, but it's kind of clumsy and setting the font to bold doesn't always work (I need to move the mouse a bit before it refreshes, even if I call chtTest.Refresh()). Is there a better way to do this? Ideally I'd like to do it using a template for AxisX, but I can't find a way to do this since the "Highlighted" property of the current point isn't accessible from the AxisX template.
Also, there seems to be no way to make the text underlined since the TextDecoration property isn't exposed. Since the labels seem to be done with TextBlocks, is there a way to do this?
Thanks in advance.