Search
Code Better
-
Recent Posts
Categories
Category Archives: Core .NET
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
Populating Fields and CRUD in ASP.NET MVC
How do we get ASP.NET MVC to populate field values in a strongly-typed Edit view? The answer is surprisingly simple: specify the model instance! In your controller, create or otherwise generate the instance you want to edit, and pass it into the returned View instance; ASP.NET MVC will fill out fields for you. 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
Unit Testing and Code-Coverage in Silverlight
You can run unit-testing and code-coverage on Silverlight applications (NUnit, PartCover, et all) with a bit of foresight and reorganization of your code. You can test core logic and classes, albeit not Silverlight-specific code. I show you how. Continue reading
Posted in Core .NET, Silverlight, Tools
Tagged automated testing, NUnit, PartCover, silverlight testing
1 Comment
Optimization 101
How do you optimize your application? Should you? When? How? We go over the basics, with six “rules” that you can follow to help you effectively improve your application performance. Continue reading
Posted in Core .NET, Silverlight, Uncategorized, Web, Wndows Forms
Tagged optimization, out of memory issues, performance, PSR
1 Comment
The “using” Statement and IDisposable
The using statement allows you to create a block of text around an object (or multiple objects), that implements IDisposable, and to have the CLR automatically call Dispose on that object (or multiple objects). Continue reading
Posted in Core .NET, Silverlight, Web, Wndows Forms
Tagged Garbage Collection, IDisposable, Object Finalization, using statement
4 Comments