Open rampaa opened 3 months ago
Depending on the application, you might be better with lower-level API in System.Windows.Media.TextFormatting
like TextLine
.
The API request is not unreasonable but also it is non-trivial to implement.
How about a Readonly TextBox ?
How about a Readonly TextBox ?
I'm already using TextBox
es by setting their IsReadOnly
property to true
, if that's what you are asking. I am also setting IsUndoEnabled
to false
, UndoLimit
to 0
and AutoWordSelection
to false
for good measure.
Background and motivation
In my app I need to get the character index from the mouse position. Even though I don't need the capabilities of a
TextBox
, becauseTextBlock
does not have a method like GetCharacterIndexFromPoint, I need to use the TextBox control instead. The issue is my app creates lots of TextBoxes (which could have been TextBlocks if a TextBlock supported the aforementioned method) and a TextBox is more resource hungry than a TextBlock. So I'd like to avoid paying the price of a TextBox unnecessarily.API Proposal
API Usage
Alternative Designs
No response
Risks
No response