Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1085401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:41:04+00:00 2026-05-16T22:41:04+00:00

This is a slightly abstract question, for which I apologize. I am not necessarily

  • 0

This is a slightly abstract question, for which I apologize. I am not necessarily looking for a specific tested solution, but rather some suggestions that I can experiment with to find the one that works the best. All suggestions are welcome – the more varied and creative the better.

Here’s the problem:

I have a Silverlight TextBlock that contains a paragraph of wrapping text. It may contain multiple runs with a variety of formatting applied, including multiple font sizes. It may be aligned left, right, center or justified and may contain runs that use right-to-left textflow. I need to be able to detect the character under the mouse pointer. In WPF I could solve this problem easily using the GetPositionFromPoint method, but since this method does not exist in Silverlight, I need a creative workaround.

One approach I have tried, with reasonable success, is to break the text into individual words and create a TextBlock for each of them. By rendering them in a WrapPanel I can identify the start position of each word and thus narrow the hit test zone. Finding the actual target character is then a matter of building the target word, character by character, until its width meets the mouse position.

Although my experimental technique works, it has two drawbacks. The first is performance, since it is expensive to render a large number of individual TextBlock instances in a WrapPanel. The second concern is that my line-breaking algorithm (crudely based on spaces and hyphens) may not exactly match that used by the real TextBlock used in the UI. Having just read the Unicode Line Breaking Algorithm, I realize that this is a whole subject in its own right. I do not want to risk a design that breaks under certain paragraph content conditions

I would ideally like to find a technique that allows me to to measure directly against the main TextBlock, but I welcome any innovative suggestions, no matter how bizarre they may appear.

Many thanks,
Tim

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:41:05+00:00Added an answer on May 16, 2026 at 10:41 pm

    Use a RichTextBox instead, that does have a GetPositionFromPoint method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a slightly noob question, but looking to clarify my thoughts
This is a slightly tricky question. I am using NSDateFormatter on the iPhone but
I know this question has been done but I have a slightly different twist
I'm not sure exactly how to describe this question, but here goes. I've got
Using a string.CompareTo(string) i can get around this slightly but is not easy to
I commented earlier on this question (Why java.lang.Object is not abstract?) stating that I'd
OK, this is a slightly weird question. We have a touch-screen application (i.e., no
I was going to post this on Database Administrators, but as it is slightly
I get a compile error, which I'm slightly confused about. This is on VS2003.
I was looking at the answer of this question regarding multiple generic types in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.