Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. var top = control.TransformToVisual(StackPanel).TransformPoint(new Point());
  2.  
  3. var controlBounds = new Rect(top, control.DesiredSize);
  4.  
  5. var viewBounds = new Rect(new Point(ScrollViewer.HorizontalOffset, ScrollViewer.VerticalOffset), new Size(ScrollViewer.ViewportWidth, ScrollViewer.ViewportHeight));
  6.  
  7. if (RectIntersects(viewBounds, controlBounds))
  8. {
  9.  
  10. }
  11.  
  12. private static bool RectIntersects(Rect a, Rect b)
  13. {
  14. return !(b.Left > a.Right
  15. || b.Right < a.Left
  16. || b.Top > a.Bottom
  17. || b.Bottom < a.Top);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement