Click here to Skip to main content
15,880,469 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Fun with Generic Enum Constraint Pin
Bernhard Hiller12-Jun-15 4:35
Bernhard Hiller12-Jun-15 4:35 
GeneralRe: Fun with Generic Enum Constraint Pin
Brisingr Aerowing12-Jun-15 11:31
professionalBrisingr Aerowing12-Jun-15 11:31 
GeneralRe: Fun with Generic Enum Constraint Pin
PIEBALDconsult17-Jun-15 5:00
mvePIEBALDconsult17-Jun-15 5:00 
GeneralRe: Fun with Generic Enum Constraint Pin
Richard Deeming17-Jun-15 5:45
mveRichard Deeming17-Jun-15 5:45 
GeneralRe: Fun with Generic Enum Constraint Pin
PIEBALDconsult17-Jun-15 5:56
mvePIEBALDconsult17-Jun-15 5:56 
GeneralRe: Fun with Generic Enum Constraint Pin
greldak25-Jun-15 21:58
greldak25-Jun-15 21:58 
GeneralRe: Fun with Generic Enum Constraint Pin
James Curran1-Jul-15 5:19
James Curran1-Jul-15 5:19 
GeneralWPF ValidationErrors Pin
Bernhard Hiller29-May-15 4:28
Bernhard Hiller29-May-15 4:28 
With WPF, you can set the NotifyOnValidationError property of some elements to true and add an error handler, e.g. Validation.AddErrorHandler(textID, ItemError);.
Starting from a vaild state, you type some nonsense into the textbox, and you receive the event with e.Action = ValidationErrorEventAction.Added. That's what we should expect.

But what happens if you type more nonsense into the textbox?
Well, you receive another vaildation error with e.Action = ValidationErrorEventAction.Added. Hm, OK, validation failed again, and the error might be different.

But now comes the WTF: immediately afterwards, you receive another such event, but now with e.Action = ValidationErrorEventAction.Removed! Yes, "Removed". Everything OK now? Can't be true, there's garbage in the textbox, not valid value.

I changed my validator to include the text of the textbox. And voila: in the "Added" event, the current text is shown;, in the "Removed" event, the previous text.
By the way, in .Net 3.5 the behavior was the other way round (first remove the previous error, then add the new error), see e.g. validationerror-giving-strange-behavior[^]
GeneralRe: WPF ValidationErrors Pin
Brisingr Aerowing29-May-15 5:11
professionalBrisingr Aerowing29-May-15 5:11 
JokeMessage Closed Pin
29-May-15 5:14
User 113800029-May-15 5:14 
GeneralRe: WPF ValidationErrors Pin
Bernhard Hiller29-May-15 5:35
Bernhard Hiller29-May-15 5:35 
GeneralRe: WPF ValidationErrors Pin
Eddy Vluggen29-May-15 5:46
professionalEddy Vluggen29-May-15 5:46 
GeneralRe: WPF ValidationErrors Pin
Brisingr Aerowing29-May-15 6:00
professionalBrisingr Aerowing29-May-15 6:00 
GeneralRe: WPF ValidationErrors Pin
Eddy Vluggen29-May-15 5:43
professionalEddy Vluggen29-May-15 5:43 
GeneralRe: WPF ValidationErrors Pin
Richard Deeming29-May-15 6:08
mveRichard Deeming29-May-15 6:08 
GeneralRe: WPF ValidationErrors Pin
Bernhard Hiller31-May-15 23:49
Bernhard Hiller31-May-15 23:49 
GeneralRe: WPF ValidationErrors Pin
Richard Deeming1-Jun-15 1:50
mveRichard Deeming1-Jun-15 1:50 
GeneralCode Puzzle Pin
Sascha Lefèvre13-May-15 15:24
professionalSascha Lefèvre13-May-15 15:24 
GeneralRe: Code Puzzle Pin
PIEBALDconsult13-May-15 15:32
mvePIEBALDconsult13-May-15 15:32 
GeneralRe: Code Puzzle Pin
Brisingr Aerowing13-May-15 15:33
professionalBrisingr Aerowing13-May-15 15:33 
GeneralRe: Code Puzzle Pin
Sascha Lefèvre15-May-15 4:26
professionalSascha Lefèvre15-May-15 4:26 
GeneralRe: Code Puzzle Pin
Brisingr Aerowing13-May-15 15:33
professionalBrisingr Aerowing13-May-15 15:33 
GeneralRe: Code Puzzle Pin
Suvabrata Roy13-May-15 21:28
professionalSuvabrata Roy13-May-15 21:28 
GeneralRe: Code Puzzle Pin
Agent__00713-May-15 21:54
professionalAgent__00713-May-15 21:54 
GeneralRe: Code Puzzle Pin
Richard Deeming14-May-15 1:19
mveRichard Deeming14-May-15 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.