Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. textbox - select all

textbox - select all

Scheduled Pinned Locked Moved WPF
wpfcsharpcom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    teejayem
    wrote on last edited by
    #1

    I know it sounds stupid but i'm looking for a way to style a textbox so that when it has focus it selects all the text. I know I could just call 'textBox.SelectAll()' (but i like to avoid x:Name). I could subclass the textbox and override OnFocus and call "SelectAll()" (but i don't like the idea). I'd really like to be able to do this in xaml by creating a style. I did a google check but came up empty :( EDIT: i just came across this solution[^]. I'm really hoping for a pure xaml solution but this will work.

    Don't be overcome by evil, but overcome evil with good

    L 1 Reply Last reply
    0
    • T teejayem

      I know it sounds stupid but i'm looking for a way to style a textbox so that when it has focus it selects all the text. I know I could just call 'textBox.SelectAll()' (but i like to avoid x:Name). I could subclass the textbox and override OnFocus and call "SelectAll()" (but i don't like the idea). I'd really like to be able to do this in xaml by creating a style. I did a google check but came up empty :( EDIT: i just came across this solution[^]. I'm really hoping for a pure xaml solution but this will work.

      Don't be overcome by evil, but overcome evil with good

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This is what I use in all my applications. http://www.madprops.org/blog/wpf-textbox-selectall-on-focus/[^]

      Cheers, Karl » CodeProject 2008 MVP, CodeProject 2009 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

      Just a grain of sand on the worlds beaches.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups