Category Archives: WPF

Windows Presentation Foundation-based desktop applications

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 , , | 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 , , | 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 , , | 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 , , | 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

Posted in Core .NET, WPF | Tagged , | Leave a comment

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

Posted in Core .NET, WPF | Tagged , | 3 Comments

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 , | 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

Posted in Core .NET, WPF | Tagged , | Leave a comment

UserControl/Page Navigation Architecture in WPF

How can you set up a WPF navigation with UserControl objects? We detail one design/architecture (for a small game): using UserControl (or Page) as a base class; creating a single Frame that switches content so change screens; and a navigation controller to encapsulate switching from control to control. Continue reading

Posted in Core .NET, WPF | Tagged , | 1 Comment