Home > error with > error with in textrange

Error With In Textrange

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting an error with TextRange method for unclear reason up vote 0 down vote favorite Im trying to highlight a TextRange in a richtextbox in wpf, However I keep getting the error below about an invalid argument, even though I am quite confident the argument is infact correct. I understand how to stop the program from crashing but if this ArgumentException is thrown then my program does not do what I wish it to. The code is below for the GetAllWordRanges Method. private static IEnumerable GetAllWordRanges(FlowDocument document, List keywords) { foreach (string keyword in keywords) { TextPointer pointer = document.ContentStart; while (pointer != null) { if (pointer.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.Text) { string textRun = pointer.GetTextInRun(LogicalDirection.Forward); MatchCollection matches = Regex.Matches(textRun, keyword); foreach (Match match in matches) { int startIndex = match.Index; int length = match.Length; TextPointer start = pointer.GetPositionAtOffset(startIndex); TextPointer end = start.GetPositionAtOffset(length); yield return new TextRange(start, end); } } pointer = pointer.GetNextContextPosition(LogicalDirection.Forward); } } } Exception Detail: System.ArgumentException was unhandled HResult=-2147024809 Message='SolidBrush' parameter type is not valid for formatting property 'Background'. Parameter name: value Source=PresentationFramework ParamName=value StackTrace: at System.Windows.Documents.TextRange.ApplyPropertyValue(DependencyProperty formattingProperty, Object value, Boolean applyToParagraphs, PropertyValueAction propertyValueAction) at System.Windows.Documents.TextRange.ApplyPro

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community http://stackoverflow.com/questions/29332860/getting-an-error-with-textrange-method-for-unclear-reason of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up IE TextRange select method not working properly up vote 7 down vote favorite 8 I'm having an unusual problem with an IE document with contentEditable set to true. Calling select() on a range that is http://stackoverflow.com/questions/130186/ie-textrange-select-method-not-working-properly positioned at the end of a text node that immediately precedes a block element causes the selection to be shifted to the right one character and appear where it shouldn't. I've submitted a bug to Microsoft against IE8. If you can, please vote for this issue so that it can be fixed. https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=390995 I've written a test case to demonstrate the effect:

 

© Copyright 2019|winbytes.org.