I see a strange behaviour dragging in Line shape over a Canvas that I cannot explain. The Line shape is in a Thumb DataTemplate like so:
<DataTemplateDataType="{x:Type vm:MyLine}"><ThumbDragDelta="Thumb_DragDelta"><Thumb.Template><ControlTemplateTargetType="Thumb"><LineFill="LightBlue"StrokeThickness="2"Y1="{Binding Y1}"Y2="{Binding Y2}"X1="{Binding X1}"X2="{Binding X2}"Stroke="LightBlue"x:Name="Line"/></ControlTemplate></Thumb.Template></Thumb></DataTemplate>
The Canvas is ItemsPanelTemplate
of
a ListBox
.
In the ListBox.ItemContainerStyle
there
is noCanvas.Top
or Canvas.Left
Binding
or Setter. Also no Binding for Width and Height.
The Line on the Canvs is dragging but it drifts away from the mouse position. Fairly wild and quick.
In code behind the dragging has the effect:
line.X1 += e.HorizontalChange; line.X2 += e.HorizontalChange;
line.Y1 += e.VerticalChange; line.Y2 += e.VerticalChange;
The setters for X..Y
raise PropertyChanged
otherwise
the Line
wouldn't
move.
What should I do for a proper dragging behaviour for Line
and
why? Binding
Mode=OneWay
makes no difference.