WPF Image Panning Constraints

前端 未结 1 1556
失恋的感觉
失恋的感觉 2021-01-15 03:11

I\'m trying to figure out how to constrain a pan so that the image remains entirely within the bounds of it\'s containing border. Any help this regard would be greatly appr

相关标签:
1条回答
  • 2021-01-15 03:43

    The following code gives you the bounds of the transformed Image control in coordinates relative to the Border control. You could easily check if the bounds are located inside the Border control.

    var rect = new Rect(image.RenderSize);
    var bounds = image.TransformToAncestor(border).TransformBounds(rect);
    
    0 讨论(0)
提交回复
热议问题