Hello again,
I would like to ask if there is a way to give a border (stroke and thickness) to horizontal and vertical line annotations.
I assume it has something to do with setting the WPF-style of the annotation element, but I’m running into a lot of errors while experimenting with this approach.
Is there an easy-to-understand example around?
Thank you verry much.
- Marc Vahldieck asked 7 months ago
- You must login to post comments
Hi Mark,
A LineAnnotation
internally uses a System.Windows.Shapes.Line
to render the actual line, and this type doesn’t have a border associated with it.
Here’s the ControlTemplate
for the LineAnnotation
:
<ControlTemplate x:Key="LineAnnotationTemplate" TargetType="a:LineAnnotation">
<Grid x:Name="PART_LineAnnotationRoot">
<Line
x:Name="PART_GhostLine"
Stroke="Transparent"
StrokeThickness="{x:Static visuals:ManipulationMargins.AnnotationLineWidth}" />
<Line
x:Name="PART_Line"
Stroke="{TemplateBinding Stroke}"
StrokeDashArray="{TemplateBinding StrokeDashArray}"
StrokeThickness="{TemplateBinding StrokeThickness}"
StrokeStartLineCap="{TemplateBinding StrokeStartLineCap}"
StrokeEndLineCap="{TemplateBinding StrokeEndLineCap}"/>
</Grid>
</ControlTemplate>
and style for LineAnnotation
<Style BasedOn="{StaticResource AnnotationBaseStyle}" TargetType="a:LineAnnotation">
<Setter Property="Stroke" Value="{me:ThemeBinding RubberBandStrokeBrush}" />
<Setter Property="StrokeThickness" Value="2.0" />
<Setter Property="Template" Value="{StaticResource LineAnnotationTemplate}" />
</Style>
I’m not sure you could alter this to use a Border
type as SciChart is expecting PART_Line in the ControlTemplate to be of type Line, which has X1 X2 Y1 Y2 properties. Border doesn’t have these.
Curious what visual effect you’re trying to achieve (and what requirement / why?) We may be able to find an alternative solution.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 7 months ago
-
I answered in another reply so I could attach am image.
- You must login to post comments
I understand, so it’s a little bit more complicated.
I experimented with the Box-Annotation. Is it possible to make the Box editable/drag-able in only one direction (for example, only dragging the box along the x-Axis) but disable the usage of the four “corner points”? Because, the “corner points” still allow for the box to be edited in x/y-direction.
Regarding the visual effect, we are trying to work closely long the visual design guideline our employer gave us. I have attached an example. As you can see, the central vertical bar in the image has a black border and an orange core.
If you can suggest an alternative, I’m all ears.
- Marc Vahldieck answered 7 months ago
- You must login to post comments
OK great to have a little more context to work with
BoxAnnotation (any annotation) can be restricted to resizing in one direction by setting the Annotation.ResizeDirections
property. You can limit dragging as well by setting Annotation.DragDirections
property.
You may also find the CompositeAnnotation feature useful. This lets you group annotations (e.g. thick line, with 2 thin lines at edges) and have X1 X2 Y1 Y2, dragging, resizing and placement like a normal annotation.
There’s some cool examples such as creating effects like this:
Does this give you enough to work with?
Best regards
Andrew
- Andrew Burnett-Thompson answered 7 months ago
-
Yes, definitely. I was not aware of the “ResizeDirections” and “CompositeAnnotation”. Both look promising. Thank you verry much.
- You must login to post comments
Please login first to submit.