Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this an Adorner BUG?
    primarykey
    data
    text
    <p>I've encountered a strange problem working with adorners.By using a class inheriting from Adorner,I try to draw a line in a ScrollViewer dynamically.It works well when the line is shorter than a particular length(about 600),but if I tried to scroll the ScrollViewer and draw the line longer,the problem came.The line appeared to be clipped and the rest part which is longer than 600 seemed to be invisible. I had checked the line's X1,X2,Y1,Y2,it seemed to be correct.Could you please give some advices?Thanks a lot!</p> <h2>Here is my Adorner Class</h2> <pre><code> internal class LinkGanttTaskAdorner : Adorner { private readonly Line child = null; private double x2 = 0; private double y2 = 0; private double x1 = 0; private double y1 = 0; public LinkGanttTaskAdorner(UIElement adornedElement) : base(adornedElement) { var brush = new VisualBrush(adornedElement); child = new Line { Stroke = Brushes.Black, StrokeThickness = 1 }; } protected override Size MeasureOverride(Size constraint) { child.Measure(constraint); return child.DesiredSize; } protected override Size ArrangeOverride(Size finalSize) { child.Arrange(new Rect(finalSize)); return finalSize; } protected override Visual GetVisualChild(int index) { return child; } protected override int VisualChildrenCount { get { return 1; } } public double X1 { get { return x1; } set { x1 = value; child.X1 = value; } } public double Y1 { get { return y1; } set { y1 = value; child.Y1 = value; } } public double X2 { get { return x2; } set { x2 = value; child.X2 = value; UpdatePosition(); } } public double Y2 { get { return y2; } set { y2 = value; child.Y2 = value; UpdatePosition(); } } private void UpdatePosition() { var adornerLayer = this.Parent as AdornerLayer; if (adornerLayer != null) { adornerLayer.Update(AdornedElement); } } </code></pre> <hr> <h2>By using the MouseMove event to Draw the line</h2> <pre><code> private void DragLinkStarted() { isMoveTask = false; isLinkTask = true; linkAdorner = new LinkGanttTaskAdorner(originalElement) { X1 = startMousePoint.X, Y1 = startMousePoint.Y }; var layer = AdornerLayer.GetAdornerLayer(originalElement); layer.Add(linkAdorner); Cursor = Cursors.Cross; } private void DragLinkMoved() { mousePoint = Mouse.GetPosition(originalElement); linkAdorner.X2 = mousePoint.X; linkAdorner.Y2 = mousePoint.Y; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload