SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components



When adding a VerticalSliceModifier to a chart, the axis label background color always shows up white, instead of the stroke color like in the examples. How can I change this property?

private void OnCreateSliceClick(object sender, RoutedEventArgs e)
       MouseButtonEventHandler mouseClick = null;
        mouseClick = (s, arg) =>
                    this.MouseLeftButtonUp -= mouseClick;

                    var mousePoint = arg.GetPosition((UIElement)this.sciStripChart.GridLinesPanel).X;

                    var slice = new VerticalLineAnnotation()
                        X1 = this.sciStripChart.XAxis.GetDataValue(mousePoint),
                        Style = (Style)Resources["sliceStyle"]


         this.MouseLeftButtonUp += mouseClick;


                        <s:VerticalSliceModifier Name="sliceModifier"/>

<Style x:Key="sliceStyle" TargetType="s:VerticalLineAnnotation">
            <Setter Property="ShowLabel" Value="True"/>
            <Setter Property="Stroke" Value="#427EF6"/>
            <Setter Property="IsEditable" Value="True"/>
            <Setter Property="LabelPlacement" Value="Axis"/>                          
  • You must to post comments

Hi Robert,

Thanks for your request. Concerning the issue, it should just work, because Background of AnnotationLabel is bound to Stroke of VerticalLineAnnotation by default.

One possible reason is that another DataContext applied to the annotation. Please ensure you don’t set it in your application.
Also I would suggest inspecting the annotation using any tool like WPF Snoop and checking where the Background property takes its value from.

It is quite easy to workaround this issue though. You should just specify the AnnotationLabel for the VerticalLineAnnotation directly:

             <s:VerticalLineAnnotation ShowLabel="False" ... >
                <s:AnnotationLabel LabelPlacement="Axis" Background="..."/>

Please try out the above and let us know if it works,

Best regards,

  • You must to post comments


I tried your workaround with no success (among several other workaround tries). I also opened up Snoop and was able to find the property to change this background color. I can change to color using Snoop, however I am still having difficulty figuring out how to change in within the application code. I have attached pictures of the Snoop findings. It shows the color is being driven from a style. Any ideas?

  • Andrew
    You need to select the node AnnotationLabel in snoop and change properties there, not lower down. Also you must have ShowLabel=False on the VerticalLineAnnotation else it will draw its own label and ignore your changes. let me know if it helps.
  • Robert Murchison
    The AnnotationLabel in snoop has the background property set to the stroke as it should be. It is deeper down at the PART_ContentHost where the property changes and successfully controls the color. ShowLabel=False is not changing this. Any other ideas? Anything else I can provide to help with this? I have tried many different things and am drawing a blank. I can change the color using Snoop at the PART_ContentHost but cannot translate this into the code.
  • Andrew
    Hi Robert, I don't know. We had this same question a few weeks ago and it seemed to work there:
  • Andrew
    If you can't get it working, send over your code and we'll take a look :)
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.