A very common scenario: you want to bind an itemsSource like a comboBox to an enumeration. At first sight, this is harder to implement than you would imagine. When you google (or Bing) for solutions, you find a lot of examples that use a separate ObjectDataProvider that calls the GetValues() method on the specified enum [...]
Archive for April, 2010
Modify Visual Studio itemTemplates
When you add new (code)files to your solution, 95% of the time you’ll make some adjustments. It only costs a few seconds to modify the generated code, but it’s mindnumbing work and most important, easily avoidable! Just edit the template that Visual Studio uses. They are contained in zip files, that you have to replace [...]
Receive change notifications of a property of your dependency property
The title might be a bit cryptic, so I’ll explain it with an example. Scenario: You have a Customer which has an editable collection of Orders. You want to receive updates when an order changes. This is a common scenario, but I’ve noticed a lot of wpf devvers still struggle with it. The trick is, [...]
Math.Round() and MidPointRounding
Hmmmm. How’s it possible that a method as simple as Math.Round() triggers me to write a post about it? By a coincidence, I stumbled upon the results of these two calls: Math.Round(4.5); //Returns 4 Math.Round(5.5); //Returns 6 I really expected them both to be 5 and 6 (or 4 and 5 for that matters). I [...]
Sql DataTypes: Float vs Decimal
I’ve never been really confident with my choices of data types in MS Sql, especially when it comes to float and decimal. So today, I’ve done some research… Here are some important findings/remarks: * The statement: “You should avoid Float whenever possible” is just WRONG. There are definitely scenarios where calculations with floats show rounding [...]