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. The Lounge
  3. Why does so much stuff in WPF not work ? [modified]

Why does so much stuff in WPF not work ? [modified]

Scheduled Pinned Locked Moved The Lounge
questionhelpcsharpwpfcom
41 Posts 31 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.
  • C Christian Graus

    All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

    modified on Monday, September 20, 2010 7:51 PM

    A Offline
    A Offline
    Abhinav S
    wrote on last edited by
    #7

    There are many such bugs in Silverlight too. Hopefully, someone is listening and will fix them soon.

    The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

    C M 2 Replies Last reply
    0
    • C Christian Graus

      Yeah, I agree, the end result is so plain cool that I'd never use winforms anymore. The issue is, why are there so many bugs that surely someone would have noticed, if any testing was done. Remember the mouse focus bug you found ? That sort of stuff just comes up far too often.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      P Offline
      P Offline
      peterchen
      wrote on last edited by
      #8

      Joe Manager assigned WPF testing to the VS2010 team, which got priority order from Sarah Managerette "If it doesn't crash on my desk, you ship it".

      Agh! Reality! My Archnemesis![^]
      | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

      1 Reply Last reply
      0
      • C Christian Graus

        All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        modified on Monday, September 20, 2010 7:51 PM

        M Offline
        M Offline
        Mark_Wallace
        wrote on last edited by
        #9

        Bright side: It's not swing[^].

        I wanna be a eunuchs developer! Pass me a bread knife!

        P 1 Reply Last reply
        0
        • C Christian Graus

          All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          modified on Monday, September 20, 2010 7:51 PM

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #10

          Focus in WPF is a pain - read this[^] article for details why.

          I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

          Forgive your enemies - it messes with their heads

          My blog | My articles | MoXAML PowerToys | Onyx

          G E R 3 Replies Last reply
          0
          • A Abhinav S

            There are many such bugs in Silverlight too. Hopefully, someone is listening and will fix them soon.

            The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

            C Offline
            C Offline
            Chris C B
            wrote on last edited by
            #11

            Mwahahahaha! I don't think we are living on the same planet. Never mind, have a five for giving me a good laugh first thing in the morning. :laugh: :laugh:

            1 Reply Last reply
            0
            • C Christian Graus

              All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              modified on Monday, September 20, 2010 7:51 PM

              P Offline
              P Offline
              Phil J Pearson
              wrote on last edited by
              #12

              Yes, I agree it's annoying that WPF TextBoxes don't behave by default the way Windows edit controls have behaved since Noah was a lad (by selecting all the text when they get focus). The fact is, however, that it's very easy to achieve this for every TextBox in your application with very little code. This is obviously not a programming question so I won't answer it here. If it was a programming question in the appropriate forum I would say: ... ... just add this somewhere in your app initialisation:

              EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotKeyboardFocusEvent,
              new RoutedEventHandler((sender, args) =>
              {
              (sender as TextBox).SelectAll();
              }));

              easy-peasy!

              Phil


              The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.

              K 1 Reply Last reply
              0
              • M Mark_Wallace

                Bright side: It's not swing[^].

                I wanna be a eunuchs developer! Pass me a bread knife!

                P Offline
                P Offline
                Phil Martin
                wrote on last edited by
                #13

                It's not that bright a side. Swing + JavaFX = lots of fun and actually pretty cool. And the added bonus is JavaFX is way easier to read than XAML.

                1 Reply Last reply
                0
                • A Abhinav S

                  There are many such bugs in Silverlight too. Hopefully, someone is listening and will fix them soon.

                  The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #14

                  Abhinav S wrote:

                  There are many such bugs in Silverlight too.

                  I'm not surprised--Silverlight seems like WPF-light, wouldn't there be some sharing of the base code? On the other hand, I'm not surprised for other reasons as well. Marc

                  1 Reply Last reply
                  0
                  • P Pete OHanlon

                    Focus in WPF is a pain - read this[^] article for details why.

                    I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                    Forgive your enemies - it messes with their heads

                    My blog | My articles | MoXAML PowerToys | Onyx

                    G Offline
                    G Offline
                    Gary Wheeler
                    wrote on last edited by
                    #15

                    My 5, and your link is now in my favorites.

                    Software Zen: delete this;

                    1 Reply Last reply
                    0
                    • P Phil J Pearson

                      Yes, I agree it's annoying that WPF TextBoxes don't behave by default the way Windows edit controls have behaved since Noah was a lad (by selecting all the text when they get focus). The fact is, however, that it's very easy to achieve this for every TextBox in your application with very little code. This is obviously not a programming question so I won't answer it here. If it was a programming question in the appropriate forum I would say: ... ... just add this somewhere in your app initialisation:

                      EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotKeyboardFocusEvent,
                      new RoutedEventHandler((sender, args) =>
                      {
                      (sender as TextBox).SelectAll();
                      }));

                      easy-peasy!

                      Phil


                      The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.

                      K Offline
                      K Offline
                      Kenneth Kasajian
                      wrote on last edited by
                      #16

                      You know, I'm not sure it's true that the Windows edit control behaves this way. I recall working with standard USER controls in Win32, and when you select a control, the text wouldn't get highlighted automatically. I had to put the highlighting coding in myself on focus.

                      ken@kasajian.com / www.kasajian.com

                      1 Reply Last reply
                      0
                      • C Christian Graus

                        All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

                        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                        modified on Monday, September 20, 2010 7:51 PM

                        P Offline
                        P Offline
                        Patrick Choiniere
                        wrote on last edited by
                        #17

                        I feel your pain. I'm trying to convert a large winforms app (with visual inheritance used all over) to WPF and I'm nearly bald now from pulling all my hair out. If anyone has any way to do visual inheritance in WPF it would make my job so much easier. As it is I now have to make my code base about 100 times bigger without it. And if anyone asks my boss asked me to convert it. I consider it a total waste of time, but he pays the bills so I'm doing it.

                        1 Reply Last reply
                        0
                        • P Pete OHanlon

                          Focus in WPF is a pain - read this[^] article for details why.

                          I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                          Forgive your enemies - it messes with their heads

                          My blog | My articles | MoXAML PowerToys | Onyx

                          E Offline
                          E Offline
                          ExportedNorwegian
                          wrote on last edited by
                          #18

                          someone desperately need a captcha tool on their blog...

                          1 Reply Last reply
                          0
                          • C Christian Graus

                            All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

                            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                            modified on Monday, September 20, 2010 7:51 PM

                            A Offline
                            A Offline
                            Adriaan Davel
                            wrote on last edited by
                            #19

                            A common practice is to show a modal dialog, then set the DialogResult value and close it, which works, except if you show a second modal dialog from the first, the minute you set DialogResult on the first you get an error saying that you can only set DialogResult if you used ShowDialog() :(( VERY frustrating... I have a workaround, but it isn't really pretty...

                            ____________________________________________________________ Be brave little warrior, be VERY brave

                            1 Reply Last reply
                            0
                            • H Henry Minute

                              I would not have been able to help with your problem, if you hadn't already solved it, as I am struggling with WPF myself. WPF appears to me to be so much more difficult than it needs to be in almost all aspects.

                              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                              A Offline
                              A Offline
                              Alan Balkany
                              wrote on last edited by
                              #20

                              "WPF appears to me to be so much more difficult than it needs to be in almost all aspects." This appears to be a characteristic of Microsoft development software in general. Unless you've done it many times before and know the quirks, doing anything new with a Microsoft development environment often runs into landmines. Things simply don't work, and tasks that should take minutes take hours or days. It's as if they see all other developers as potential competition, and put roadblocks in the way to slow them down.

                              H B 2 Replies Last reply
                              0
                              • P Phil Martin

                                It is a constant source of frowning for me. After decades of activity in UI software development that the tools to design, create and maintain them are still so so so hard to use, fragile and seemingly ill-fitting to the problem domain. One would think after so much research, use and development it would be a solved problem by now. Sigh. One of the funniest and representative moments for me was when I started doing C# work. I had been working in the Java desktop space for a few years and was very familiar with it, particularly layout managers. Come Java 1.5 and 1.6 they had released a set of new layout managers and modified the core part of swing to support them (aligning to text baselines, so obvious in hindsight). They were fantastic. They solved layout issues so easily and superseded all the grid layouts and previous hacks people used to work around things. I love you GroupLayout. Then I moved to C#, and imagine the surprise when the layout mechanisms were the same as Java's, but from 4 years prior. Grid layout, flow layout and docking along edges. Sigh. Insert sad smiley here. On a related topic, I miss Java 1.5 synchronization mechanisms. They made things so much easier. java.util.concurrent - I miss you.

                                D Offline
                                D Offline
                                dojohansen
                                wrote on last edited by
                                #21

                                Just out of curiosity, what are those Java 1.5 sync mechanisms?

                                P 1 Reply Last reply
                                0
                                • C Christian Graus

                                  All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

                                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                  modified on Monday, September 20, 2010 7:51 PM

                                  A Offline
                                  A Offline
                                  agolddog
                                  wrote on last edited by
                                  #22

                                  I'm going to ramble a little bit, then ask a serious question (although it doesn't sound serious, I mean it to be--I really don't understand). Christian, I agree with the frustrations of learning WPF. Some of it is fooling around until I have the lightbulb moment, but some seems just inexplicable. Example: I've created a dll with a bunch of core-level domain classes. Nothing to render in that package, strictly business-logic domain objects. This is simply referenced off of a shared drive (or off my local version, if I've been working with it). Next, I've created some user controls in my WPF application. In the same namespace as the app, just in a folder not-ingeniously named "UserControls". When working on the controls, VS renders them just fine. Finally, I add those controls to WPF forms by giving an xml namespace to my app's namespace (like "xmlns:local="appnamespace"), then adding a tag like local:myUserControl .../. The form won't render sometimes, saying it can't load the core dll, or one of its dependencies. This is obviously crap, as a) the control itself can render just fine and b) the application doesn't have any problem reading the dll when getting fired up for testing. I rather suspect it's something to do with rendering the XAML of the control into the XAML of the form, but I haven't been able to figure out why yet. (This morning, I went back to the form and it's rendering fine. Maybe something about forcing VS to lose and reestablish connection to the dll overnight?). /rant OK, now for the question: The people I work with are just in love with forms applications, and I really don't understand it. Why not just build web applications? Instead of having to worry about building an install which ensures that the machine on which my forms app being deployed has all these dependent things, just worry about keeping the web server(s) aligned with development. Why not build an application which is available anywhere on the planet (with a connection) to anyone (with a broswer), instead of limiting yourself to windows-based computers? It seems to me that it's much easier to build and deploy web applications, and there's a lot more knowledge out there how to do that, rather than the specialization of forms apps. Also that anything that can be delivered through forms can be delivered through a browser, so why not take the road that's easier? Or is that just my web background, and things really are easier with forms that I'm not getting?

                                  B F 2 Replies Last reply
                                  0
                                  • C Christian Graus

                                    All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

                                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                    modified on Monday, September 20, 2010 7:51 PM

                                    D Offline
                                    D Offline
                                    dojohansen
                                    wrote on last edited by
                                    #23

                                    What I don't understand is why the WPF designers don't include support for this *extremely common* behavior out-of-the-box. A simply "AutoSelect" property (bool) would suffice, and then it wouldn't be very important whether it was true or false by default. However, I don't think this is *specifically* the WPF textbox. At least my quick try in Windows Forms and WPF yielded the same result. I used the GotFocus event in WPF and the Enter event in Windows forms, and the event handler simply does this: ((TextBox)sender).SelectAll(); I am not sure why this works perfectly well if you tab to the textboxes, but not at all if you click in them. It seems that clicking inside a textbox clears the selection, which of course is what you want if the box is already focused when the click occurs. And I'm sure if you think about it, in general you *do* want a control, including a textbox, to receive first focus and then the click event if it's clicked in a non-focused state. That would lead to this issue when calling SelectAll in the GotFocus event handler. But all this really boils down to is that it's an all-the-more important oversight not to support this feature directly in the textbox itself, so we simply turn it on!

                                    1 Reply Last reply
                                    0
                                    • C Christian Graus

                                      All I want is, when I click on a text box, the text is all selected so the user just has to type to wipe it. All the xxx events do not work, only the Previewxxx events get called. Still not sure why. I tried PreviewGotFocus. The text gets focused, then when I lift the mouse, the focus is lost. I don't handle any other events on these controls. So I handle PreviewMouseUp. This seems to work, but there appears to be a bug in WPF. If I call SelectAll() on the control, it toggles, if I click on a control, then click on another, then click back, it DESELECTS all. So, I tried adding code to clear the selection first, makes no difference. Then I added code to manually set the selection. This works, BUT, now when I have selected the text, the app will take no more mouse input until I focus on another window, then focus back. I added code to set the focus to the control, this makes no difference. This mess is what I have now, and it still does not work. private void ProcessMouseUp(object sender, MouseButtonEventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { tb.Select(0, 0); tb.SelectAll(); tb.SelectedText = tb.Text; tb.Focus(); } } I googled it and found a class that does what I want. Yes, you have to write your own control to do this. I wasn't asking for help anyhow, my question remains, why is this so complicated ? Why is it so buggy ?

                                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                                      modified on Monday, September 20, 2010 7:51 PM

                                      M Offline
                                      M Offline
                                      M i s t e r L i s t e r
                                      wrote on last edited by
                                      #24

                                      Isn't that like ALL of MS stuff... ? Get it out the door fast so everybody adopts it... then start working on the next "new big" thing Dropping support for the previous stuff they create.. ?

                                      1 Reply Last reply
                                      0
                                      • D dojohansen

                                        Just out of curiosity, what are those Java 1.5 sync mechanisms?

                                        P Offline
                                        P Offline
                                        Phil Martin
                                        wrote on last edited by
                                        #25

                                        If you are familiar with reading the Java documentation, here is a good reference[^]. If you aren't, heres a super duper quick summary: Future : A nice representation of the concept "Something that produces a T, but we're not sure when it'll be ready" Sync mechanisms: CountDownLatch - allows one or more threads to wait until a set of operations being performed in other threads completes. CyclicBarrier - allows a set of threads to all wait for each other to reach a common barrier point. Exchanger - two threads can exchange objects. SynchronousQueue - A blocking queue in which each put must wait for a take, and vice versa DelayQueue - a queue of delayed elements, and you can only take from the queue when it's delay has expired. Containers: CopyOnWriteArrayList/Set - A thread-safe variant of ArrayList in which all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array. And it had a whole bunch of thread pooling and task execution niceties. The counter to all of this is "yes, but .Net has, and that and this over here", but the big difference here was that java.util.concurrent was cohesive and really nice to use.

                                        B 1 Reply Last reply
                                        0
                                        • A Alan Balkany

                                          "WPF appears to me to be so much more difficult than it needs to be in almost all aspects." This appears to be a characteristic of Microsoft development software in general. Unless you've done it many times before and know the quirks, doing anything new with a Microsoft development environment often runs into landmines. Things simply don't work, and tasks that should take minutes take hours or days. It's as if they see all other developers as potential competition, and put roadblocks in the way to slow them down.

                                          H Offline
                                          H Offline
                                          Hiro_Protagonist_
                                          wrote on last edited by
                                          #26

                                          Don't know if this is really the case. For about half a year I learned Java/ Eclipse/ Hibernate/ etc. All the tools that are integrated in Microsoft environment are there open source and must be understood. It is no way better. But agreed: There are plenty of things that could be done better. The worst thing is, that MS only does things when they're well known. It could be more innovative :-) Cheers Hiro

                                          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