dotnet / dotnet/wpf

Please add properties to WPF for traversing Parent/Children nodes

Open
#10,095 7 comments 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

I'm trying to write a converter to convert a [text selection](https://learn.microsoft.com/en-us/dotnet/api/system.windows.documents.textrange) from [`FlowDocument`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.documents.flowdocument) to some other text format.

# Current Situation

Currently, this is impossbile as all the navigating methods and properties are internal to the WPF framework.

The only workaround is to serialize the selected nodes to XAML using a [`XamlWriter`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.markup.xamlwriter) and using an [`XmlReader`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmlreader) or similar to traverse the generated XML.

The current solution is very cumbersome, slow, memory intensive and unnecessary.

# Desired Situation

Please add `Parent` and `Children` properties to the [`DependencyObject`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.dependencyobject) class, so we can traverse through any WPF object tree.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.