Thursday, January 31, 2008


I passed both the National Registry EMT-Basic and North Carolina EMT-Basic certifications in December and January respectively. Soon I will be volunteering with a local EMS unit, probably at night. In March I will be taking Wilderness EMT training and finally in August I start Paramedic school. Lots of fun to be had in the near future!

Thursday, January 24, 2008

Where the &%$@ is HashSet?

If you've created a .Net 3.5 project in Expression Blend 2 (December Preview) and then opened it up in VS2k8, you may have noticed that using System.Collections.Generic does not give you HashSet.
The type or namespace name 'HashSet' could not be found.
You may be gnashing your teeth over this, but the simple solution is to add System.Core.dll as a reference to your project because it appears Blend 2 leaves this out.

Update: Zoom multiple controls from the same slider in XAML

I've had a serious learning curve with XAML, and frequently find new and better ways of doing things. A good example of this is zooming multiple controls from the same slider. My previous solution used a DependencyProperty and an IValueConverter and was probably slow as dirt if you wired up more than a few controls to get zoomed. A much more succinct, maintainable, and readable solution would be:
<Page class="ZoomTest.Page1" name="page" xmlns="...">
<ScaleTransform ScaleX="{Binding Path=Zoom,
ScaleY="{Binding Path=Zoom,
ElementName=page}" />
And yes, while I do have two bindings, it actually is very fast. One of the big things I've learned is you can really (ab)use the binding system and strangely enough have a faster UI than one you control! In a GUI application I'm designing in WPF, there are over 5000 data bindings on just one page, and yet it is nearly twice as fast as the version where I practically precompute the whole UI! My only guess as to why this is the case is that UIElement's are much more expensive than data bindings.

Another way to tackle the above problem, if say you're on the same UI without Page's, is actually much simpler:
<Window ...>
<DockPanel x:Name="LayoutRoot"
<StackPanel DockPanel.Dock="Top">
<Slider x:Name="ZoomSlider"
Minimum="1" Value="5" Maximum="10" />
<Grid x:Name="content">
<ScaleTransform ScaleX="{Binding Path=Value,
ScaleY="{Binding Path=Value,
ElementName=ZoomSlider}" />
Using strategies like this you can use less C# and more XAML. I've been able to take over 7000 lines of presentation code written for Java 1.4 (the C# 2.0 code would be roughly the same size) and turn it into roughly 550 lines of XAML and 100 lines of C# 3.0. Expect more little fun things you can do with WPF soon (like making a ListBox do whatever you please).