Silverlight Upper-Case TextBox(janrep.blog.codeplant.net)

submitted by janrepjanrep(365) 3 years, 2 months ago

Silverlight TextBox does not implement CharacterCasing property , but with simple KeyDown handling code we can implement similar functionality and we can create TextBox that works in upper-case mode.

1 comment |category: |Views: 172

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by mikewmikew(0) 2 years, 2 months ago 0

Thanks for the starter on this. A slightly better version that takes into account selected text that you overwrite by typing.

if (!(sender is TextBox)) return;

//do not handle ModifierKeys
if (Keyboard.Modifiers != ModifierKeys.None) return;
if ((e.Key < Key.A) || (e.Key > Key.Z)) return;

TextBox tb = (TextBox)sender;

string s = new string(new char[] { (char)e.PlatformKeyCode });
int selstart = tb.SelectionStart;
tb.Text = tb.Text.Remove(selstart, tb.SelectionLength);
tb.Text = tb.Text.Insert(selstart, s);
tb.Select(selstart + 1, 0);
e.Handled = true;

Reply

information Login or create an account to comment on this story