Open shersh opened 8 years ago
I agree with you, Roman, we should reuse the current instance of the Transform. I've just submitted a PR with a potential fix.
If the Transform was been made a ScaleTransform than why would you want to use the DragPositionBehavior?
Hi Shawn: for the specific case of the DragPosition Behavior the transform must be a TranslateTransform for obvious reasons. However in the future we could take the DragPositionBehavior as a starting point for other Behaviors like Zoom / Rotate, and in that case the tranform will have to change.
I think I misunderstood the original statement. You want to do scaling and moving of an object? If that is the case then the behavior should set the transform to a CompositeTransform IFF the transform is null, it should not reset it
The proposed fix is initializing the RenderTransform with a new CompositeTransform when the DragPositionBehavior is attached:
///
/// Initialises the private fields used by the Behavior.
/// Called when Behavior is attached.
///
/// private void initialise(FrameworkElement element) { element.RenderTransform = new CompositeTransform(); }
Is this solution solving the issue Roman?
In DragPositionBehavior.cs after pointer is pressed RenderTransform will be replaced by TranslateTransform. That is bad. Because if we have already changed it for example to ScaleTransform or CompositeTransform it will be replaced and we can't using old version.