wpf - Handle all Hyperlinks MouseEnter event in a loaded loose Flowdocument -


I am working on my first project, am new to WPF. I am stuck in this problem for a week so I am trying to find some help here.

I have a flow document reader inside my app, which loads many flow documents (free files as loose xaml files).

I have to handle MouseEnter events for all hyperlinks in the loaded document, but I can not set MouseEnter = "myHandler" in XEML because asese are loose XAML files.

Is there any way to set up a time when parsing the flow document and setting headlars?

Any other solution? Sorry for the newbie question, thanks a lot in advance.

After loading your flow document you LogicalTreeHelper < You can calculate all UIElements using the / code>. This will allow you to find all hyperlinks. Then you can just subscribe to your MouseEnter event. Here is a code:

  Zero substratohylaherlinks (Object Sender, Routing Event E) {var hyperlinks = GateVisuals (this ). OFTIPES & LIFT; Hyperlink & gt; (); Foreach (Miscellaneous links in hyperlink) link.MouseEnter + = Hyperlink_MouseEnter; } Public stable IEnumerable & lt; DependencyObject & gt; GetVisuals (Dependent Object Root) {foreach (Different types of children in LogicalTreeHelper.GetChildren (Route) .Of Type & Lt; Dependency Object & gt; ()) {yield returns child; Fortnight (Various offspring (children) in gativisuals yield returns warrant; }} Private Zero Hyperlink_MouseEnter (Object Sender, MouseEventArgs E)   

I tested it with XAML:

 < Code> & lt; FlowDocumentReader & gt; & Lt; FlowDocument & gt; & Lt; Paragraph & gt; & Lt; Hyperlink & gt; Asf & lt; / Hyperlink & gt; & Lt; / Paragraph & gt; & Lt; / FlowDocument & gt; & Lt; / FlowDocumentReader & gt;    

Comments