Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

TextBlock - inlines & datagrid

$
0
0

What is the correct way to add inlines to a TextBlock using code?

Scenario:1) we have behavior that adds inlines to highlight text that match search criteria.
2) data grids with columns containing textblock with this behaivor

Issue is data grid context menu doesn't beahve the same (doesn't modify selection) if clicking on the runs since they are not visual elements/UIElements & data grid tries to cast original source to UIElement thus getting a different behavior. This does not seem to be the case when only setting the "Text" property of the TextBlock (run will not be source of the event).

One workaround is disabling IsHitTestVisible but this is maybe not always wanted & there are a lot of places affected.

But maybe there is another way to add runs that creates the normal behavior? Runs seems to be part of logical tree rather than visual tree.





Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>