VisualHelper.cs 862 B

12345678910111213141516171819202122232425262728
  1. using System.Windows;
  2. using System.Windows.Media;
  3. namespace SHJX.Service.WorkFlowEdit
  4. {
  5. public static class VisualHelper
  6. {
  7. public static T FindParent<T>(this DependencyObject value) where T : DependencyObject
  8. {
  9. DependencyObject parent = value;
  10. while (parent != null && !(parent is T))
  11. parent = VisualTreeHelper.GetParent(parent);
  12. return parent as T;
  13. }
  14. /*public static Point GetWindowPosition(this System.Windows.Input.MouseEventArgs e, DependencyObject relativeTo)
  15. {
  16. var parentWindow = Window.GetWindow(relativeTo);
  17. return e.GetPosition(parentWindow);
  18. }*/
  19. /*public static Point ClientToScreen(this UIElement value, Point point)
  20. {
  21. var parentWindow = Window.GetWindow(value);
  22. return value.TranslatePoint(point, parentWindow);
  23. }*/
  24. }
  25. }