1

I am working on an autocomplete search box in a Windows 8 app. The box needs to allow typing and then have text show up beyond the cursor, in a different color.

Our current approach is to layer one textbox on top of the other, but it seems to me like there could be a better way.

On iOS/Mac I could do this with an NSAttributedString, but I don't know if an equivalent like that exists on WinRT/.NET.

(For those that don't know, an NSAttributedString is a string that allows you to set attributes like color or size on different sections)

Randall
  • 14,691
  • 7
  • 40
  • 60
  • I think your current approach is probably easiest. There's nothing like "attributed strings", but you might be able to achieve something like it using glyphs. I don't know much about them, but there's some good info here: http://stackoverflow.com/q/3956673/1001985 – McGarnagle Sep 09 '13 at 19:59
  • Looks like I was wrong ... `FormattedText` seems to be a pretty close equivalent to NSAttributedString: http://msdn.microsoft.com/en-us/library/system.windows.media.formattedtext.aspx (I'm not sure if this is available for WinRT, though?) – McGarnagle Sep 09 '13 at 21:20

1 Answers1

0

I usually approach that by auto-completing the text and marking the completed part as selected, so when the user continues typing - the selected part gets replaced by typed in characters. I doubt this will give you the specific visual effect - with no highlight, but changed text color, but I'd claim this is the only feasible and reliable solution.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100