Code Better
-
Recent Posts
Categories
Category Archives: WPF
Visual Studio Automatic Version Numbering
Visual Studio (2010+) allows you to specify that it should generate (incremental) build versions for your projects. The syntax is quite simple (for AssemblyInfo.cs), but there are a few caveats to know. Continue reading
Posted in Silverlight, Tools, Web, Wndows Forms, WPF
Tagged assembly versions, visual studio, visual studio 2010
Leave a comment
Finding Circular Dependencies in SQL Server
SQL Server doesn’t allow a cycle of foreign keys, nor two or more paths to cascadingly delete rows from a table. Thankfully, there’s a script you can use to detect at least table reference cycles. Continue reading
Posted in Libraries, Web, Wndows Forms, WPF
Tagged Cascade, Foreign Keys, SQL Server
Leave a comment
Using NInject For Compile-Time AOP
An update to my aspect-oriented design pattern for compile-time checking: you can implement aspects as interfaces with singular implementations, and use Ninject to inject the interface implementations. Smooth, easy, and it works! Continue reading
Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF
Tagged aspect-oriented programming, dependency injection, design patterns
Leave a comment
Enums, SQL Server, and Null
Ever wonder how to deal with enumerations that might be null? Should you have a “nothing” value? What about SQL Server? As it turns out, enumerations are value types (often represented by integers), which means that they can be nullable! Continue reading
Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF
Tagged enumerations, null, nullable types
Leave a comment
WPF Brushes: Solid, Gradient, Image, and More!
WPF objects take a Brush instance (an abstract class) for foreground and background colours. What is a legitimate brush, exactly? Surprisingly, it can be a solid colour, or a gradient (linear or radial); it can even be an image, or something more complicated (a compound image of sorts). The MSDN page gives the best overview of brushes, visually. Continue reading
WPF Gotcha: Mouse* Event With a Backgroundless StackPanel
WPF’s StackPanel mouse events (MouseDown, MouseLeftButtonDown, and MouseRightButtonDown) don’t seem to work, even when the StackPanel is visible. That is, until you add a background of some colour and transparency. Strangely, this causes the events to fire — even though it was visible before. Continue reading
Limiting the Number of Results from LINQ
How can you limit the number of objects returned from a LINQ query, i.e. only request the first N objects (similar to MySQL’s LIMIT keyword)? The answer is via the Take(n) LINQ method; it pulls the first N rows specified. Continue reading
Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF
Tagged LINQ, LINQ for collections
Leave a comment
Adding Objects to a Window or Page via a StackPanel
You can’t directly (programmatically) add controls to a Window or a Page in WPF. So how do you add controls? Simply add a StackPanel component, and add controls via the someStackPanel.Children.Add(someObject). Similarly, you can iterate to find controls from it. Continue reading