Pooling Buffers for Better Memory Management

Occasionally, you need a more robust solution to solve a problem. In my last post, I wrote about the horrors of this small code snippet: [code language=”csharp”] public byte[] Serialize(object o) { using (var stream = new MemoryStream()) { MySerializer.Serialize(stream, o); return stream.ToArray(); } } [/code] One way to alleviate the memory pressure that can…

Hey, Who Stole All My Memory?

Sometimes a little piece of seemingly innocuous code can cause a significant amount of trouble: [code language=”csharp”] public byte[] Serialize(object o) { using (var stream = new MemoryStream()) { MySerializer.Serialize(stream, o); return stream.ToArray(); } } [/code] Doesn’t look like much, but I’m sure we have all written something like this and paid it no mind.…

Windows 8 GridView and Variable-Sized Items

The GridView control is one of the most used layout controls within Windows 8 Store applications.  By using the Grid App project template with Visual Studio 2012, your first page will look similar to the following: While this looks great, what if you’d like to create a items that vary in size?  Something like the…

Programmatically uninstalling Silverlight Out-Of-Browser Application

Every once in a while there comes a need to provide a mechanism to uninstall your application programmatically.   For Silverlight Out-Of-Browser applications , there seemed to be no way to accomplish it.  Fortunately, there’s a work-around that trusted OOB applications running in Windows can use. Silverlight OOB applications are launched via the “sllauncher.exe” command.  And…

Working with PivotViewer and the CxmlCollectionSource

Microsoft’s PivotViewer control is an amazing tool for visualizing data and creating a unique UI for your application.  The one issue everyone seems to have with it, however, is its lack of styling capability.  In fact, working with PivotViewer in Expression Blend yields little in the way of styling or templating.  There are only a…

The Cascade Game: From Silverlight to HTML5 (part 2)

Game Loops and Timer-Based Animations Previous Entries in Series Part 1 – Introduction and Game Layout My next short term goal was to get some of spheres to show and animate. And that was going to entail using HTML5’s new <canvas> tag. I saw two ways of going about animating the spheres. The first way…

The Cascade Game: From Silverlight to HTML5 (part 1)

A few years ago I played a game on Facebook that had a simple premise, but became quite addictive for a while.  It consisted of progressing levels of spheres in which the player was tasked with exploding by initiating a chain-reaction.  You had one shot.  Placement, timing, and luck determined how well you scored.  At…

Where’s my DataContext?

Every now and then a question comes up concerning a missing DataContext.  The questions usually center around a ViewModel being set to a View properly, but then developer can not bind some command or property to a FrameworkElement.  And typically the FrameworkElement in question is nested within an ItemsControl’s ItemTemplate or other similar structure. First…

Yet another way to attach ViewModels to Views

Throughout the short history of the MVVM design pattern, several methods have originated for populating Views with their ViewModels.  One of the most common methods is to use one of the frameworks (PRISM, MVVM Light, Jounce, among others).  Typically, the ViewModel is registered with an IOC container and retrieved when needed.   One of the more…

Silverlight Memory Leaks and AutomationPeers

Using a memory profiling tool such as ANTS Memory Profiler from Red-Gate or MemProfiler from SciTech Software (I’m sure there others, but those were the only two I found that can profile a Silverlight Out-Of-Browser application) is a good idea.  By using such a tool, developers can discover a myriad of memory leaks and fix…

Resumable downloads in Silverlight Out-Of-Browser applications

The task facing us is simple.  In fact, it has been done before.  Many download management tools already have the ability to resume downloading a file if, for some reason, the process was interrupted.  There is no built-in facility for resuming an interrupted download within a Silverlight applications.  Silverlight does provide some tools for working…

WPF – Animating multiple elements simultaneously

A question appeared on StackOverflow asking how to animate a property on multiple elements from one or more trigger mechanisms (i.e. a button click or list box selection).  The traditional approach (for brevity’s sake, I omitted the Xaml comprising the actual UI elements) is rather straight-forward: <Window.Resources> <Storyboard x:Key="OnClick1"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textBlock1" Storyboard.TargetProperty="(UIElement.Opacity)"> <SplineDoubleKeyFrame KeyTime="00:00:00"…