We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 19611ad commit 88ec7b9Copy full SHA for 88ec7b9
1 file changed
ICSharpCode.AvalonEdit/Utils/ExtensionMethods.cs
@@ -213,7 +213,15 @@ public static IEnumerable<DependencyObject> VisualAncestorsAndSelf(this Dependen
213
{
214
while (obj != null) {
215
yield return obj;
216
- obj = VisualTreeHelper.GetParent(obj);
+ if (obj is Visual || obj is System.Windows.Media.Media3D.Visual3D) {
217
+ obj = VisualTreeHelper.GetParent(obj);
218
+ } else if (obj is FrameworkContentElement) {
219
+ // When called with a non-visual such as a TextElement, walk up the
220
+ // logical tree instead.
221
+ obj = ((FrameworkContentElement)obj).Parent;
222
+ } else {
223
+ break;
224
+ }
225
}
226
227
0 commit comments