Hello,
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"]
};
sliceModifier.VerticalLines.Add(slice);
};
this.MouseLeftButtonUp += mouseClick;
}
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
<s:VerticalSliceModifier Name="sliceModifier"/>
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
<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"/>
</Style>
- Robert Murchison asked 8 years ago
- You must login 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="..."/>
</s:VerticalLineAnnotation
Please try out the above and let us know if it works,
Best regards,
Yuriy
- Guest answered 8 years ago
- last edited 8 years ago
- You must login to post comments
Yuriy,
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?
- Robert Murchison answered 8 years ago
- 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.
- 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.
- Hi Robert, I don't know. We had this same question a few weeks ago and it seemed to work there: https://www.scichart.com/questions/question/how-to-change-the-label-background-color-of-a-verticallineannotation
- If you can't get it working, send over your code and we'll take a look :)
- You must login to post comments
Please login first to submit.