Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows.Media;
- namespace System.Windows
- {
- public static class UIElementExtentions
- {
- public static T FindVisualParent<T>(this UIElement element) where T : UIElement
- {
- UIElement parent = element;
- while (parent != null)
- {
- T correctlyTyped = parent as T;
- if (correctlyTyped != null)
- {
- return correctlyTyped;
- }
- parent = VisualTreeHelper.GetParent(parent) as UIElement;
- }
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment