Exemplo n.º 1
0
 public static DependencyObject GetVisualParent(this DependencyObject dependencyObject)
 {
     dependencyObject.AssertNotNull(nameof(dependencyObject));
     return(dependencyObject.CaseType((Visual v) => VisualTreeHelper.GetParent(v)).
            CaseType((FrameworkContentElement f) => f.Parent).
            Default(o => throw new NotSupportedException($"DependencyObject.GetVisualParent() does not support type {o.GetType().Name}. \n " +
                                                         $"The only supported types are {typeof(Visual).Name} and {typeof(FrameworkContentElement).Name}.")).
            Result);
 }