![](/img/trans.png)
[英]How can I get 10 entries from a database, ordered by score, given a starting position, using Entity Framework?
[英]How can I get the color of a character from a given position in a text?
我基本上想檢查文本中給定位置的字符是否是某種顏色。 例如
if(character.inAposition == blue){
change characters color
}
這就是我最初更改文字顏色的方式
TextPointer start = position.GetPositionAtOffset(indexInRun);
TextPointer end = start.GetPositionAtOffset(word.Length);
TextRange rangeText = new TextRange(start, end);
rangeText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Blue);
其中indexInRun是與“ word”匹配的任何子字符串的起始索引
您不能檢查字符。 您可以檢查RichTextBox Inlines集合的Run元素。 但是您必須檢查它是否確實是Run或其他內容,例如完整的TextBlock或Image等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.