End of PDC 2008

October 31, 2008

I just got back to NYC after spending six days in Los Angeles, attending the PDC.  It was my first time attending a conference of such massive proportions.  If you have never attended one, I suggest you do.  Aside from the exciting material covered by some (certainly not all) of the sessions, it also provides you with a great way to meet people and make professional contacts.  Also, you end up leaving with a veritable mountain of crap…err “swag”…that you can eventually throw away after you lug it all home.

I was blown away by how much interest and enthusiasm I saw for WPF.  Most of the WPF sessions (i.e. presentations about WPF) were packed, and even had overflow rooms that were packed.  I think a lot of people are starting to see WPF as the future of desktop Windows programming, not as just some interesting “thing” that Microsoft is promoting.  The session about the new WPF DataGrid and Ribbon controls had two overflow rooms!

I’d like to thank Infragistics, my employer, for sending me out there.  I’d also like to thank the great people I met out there, who made the experience so enjoyable and interesting.  It was great to finally meet many of the WPF Disciples, and other folks, with whom I had only ever communicated via e-mail in the past.


Dinner with Dr. WPF (continued)

October 30, 2008

As Walt recently mentioned here, a few WPF Disciples got together for dinner last night.  Sitting at the table was none other than Dr. WPF in the flesh.  I won’t repeat everything Walt so vividly depicted, but there are some other aspects of that experience worth noting.

I had never heard someone request a side order of XAML before; neither had the waitress.  After she told the good Doctor that they did not have XAML on the menu, he burst into hysterical laughter while threatening to “initiate a furious bout of fisticuffs.”  What can you expect from a guy who drinks kool-aid by the gallon?

After that uncomfortable episode ended, the Doc explained to us, in great detail, how man can control the movement of the Loch Ness monster through animation of TranslateTransforms and RotateTransforms.  I didn’t quite follow, but it sounded very interesting.    He lost me when he mentioned that his plan requires “one brave scuba diver to dive down to Nessy and assign the transform group to her bosom.”

When the steaks arrived, the Doc expressed discontent with the size of his meal.  He kept touching the steak with two fingers and sliding them apart.    Eventually he gave up and started to eat his meal, grumbling about some missing resource key.

Release: Crack.NET v1.1

October 25, 2008

I just released an updated version of Crack.NET!  It contains a lot of bug fixes, and a few minor new features.  I wrote more about this new release in the “Latest News” section on the Crack.NET home page.  You can download the new binaries here, or get the latest source code drop here.  This version of the tool is much better than the previous one, so I recommend you grab it if you want to be a crackhead.  😀

On the home page, I mention that I’ve rounded up a group of talented individuals who are going to contribute to the project.  I’ve dubbed the group “The Cartel”.  To see who is in The Cartel, check out the “Latest News” section here.

New release of Crack.NET on CodePlex

October 21, 2008

I fixed some of the issues in Crack.NET and created a project for it on CodePlex.  Crack.NET now works on 64-bit operating systems (though it only can work with 32-bit applications).  I fixed the problem of having the InjectedWindow pick up globally typed Styles and DataTemplates from the application under observation.  Also, I added in a transition animation when you click on hyperlinks in Memory Explorer, which makes that UI more user-friendly.

What are you waiting for?  Go get it! 😀

Crack.NET on CodePlex: http://www.codeplex.com/cracknetproject

Crack.NET home page: http://www.cracknetproject.com

Introducing Crack.NET

October 20, 2008

I have been working a lot on a new developer tool, called Crack.NET.  It is similar to Mole in that it allows you to walk an object graph on the managed heap, and similar to Snoop in that it injects itself into another .NET application and reports back information to you.  It works for WPF applications, as well as Windows Forms applications.

However, on top of that functionality, I added in the ability to write and execute IronPython scripts that run inside the other application.  Those scripts can do, well…pretty much anything.  The possibilities are mind-boggling.

I wrote an article about Crack.NET and put it on the tool’s home page.  The binaries and source code are available on that page, as well.  Here’s the link:


I’ve been working non-stop on Crack.NET for almost 48 hours.  Time for some sleep…  😀


Showing an Ellipsis for Clipped Text in a ComboBox

October 11, 2008

If you have a ComboBox with a fixed width, and the selected item is wider than that width, it will be clipped.   That is OK, but it’s nice to let the user know that there is more text than what can be seen.  A common way to do that is by having the text show an ellipsis (…) at the end.  If you do not show the ellipsis, the ComboBox looks something like this:

With the ellipsis, it looks like this:

There are two ways to do this, both of them involve a DataTemplate that contains a TextBlock whose TextTrimming property is set to ‘CharacterEllipsis’.  If you populate the ComboBox by setting its ItemsSource property, you must apply the ellipsis via the ItemTemplate property.  On the other hand, if you populate by adding ComboBoxItems to the Items collection directly, you should create a Style for ComboBoxItem that sets the ContentTemplate to the same DataTemplate you’d use in the other situation.

Here’s an example for setting ItemsSource:

Here’s an example when adding the items directly inline:

Download the demo project here.  Be sure to change the file extension from .DOC to .ZIP and then decompress it.

Binding to (Validation.Errors)[0] without Creating Debug Spew

October 8, 2008

Microsoft’s documentation that shows how to display validation errors for elements says to use a binding like this:

This works, but it causes reams of debug spew to fill the Output window.  Why?  Because is tries to access the first item in the Validation.Errors attached property collection, but if there are no errors, an exception is thrown.  Here’s the type of debug spew that fills the output window:

System.Windows.Data Error: 16 : Cannot get ‘Item[]’ value (type ‘ValidationError’) from ‘(Validation.Errors)’ (type ‘ReadOnlyObservableCollection`1′). BindingExpression:Path=(0).[0].ErrorContent; DataItem=’TextBox’ (Name=’symbolTxt’); target element is ‘TextBox’ (Name=’symbolTxt’); target property is ‘ToolTip’ (type ‘Object’) TargetInvocationException:’System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
at System.Collections.ObjectModel.ReadOnlyCollection`1.get_Item(Int32 index)
— End of inner exception stack trace —
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)’

I use the Output window all the time for debugging purposes, so having it fill up with these error messages breaks my workflow.  I decided to find a better way to display error messages, such that the Output window is not clogged with garbage.  Here’s what I came up with:

When you run my demo app, it looks like this:

The trick is to bind a ContentPresenter’s Content to the CurrentItem of Validation.Errors for the target element.   Binding to the CurrentItem means that we’re  binding to the CurrentItem property of the default ICollectionView that wraps the ReadOnlyObservableCollection<ValidationError> returned by the attached Errors property.  When the current item is non-null, that means there is a validation error; when it is null, there are no validation errors.  We can rely on ICollectionView to safely access the validation error, or not return anything if there are no errors.  That is what prevents the debug spew from pouring out.

The DataTemplate declared in the StackPanel’s Resources knows how to render a ValidationError object.  If the ContentPresenter has a null value, the template is not used to render anything.   That template could also render in a tooltip, if you prefer to keep with Microsoft’s example of showing validation error messages in a tooltip.

Download the demo project here.  Be sure to change the file extension from .DOC to .ZIP and then decompress the file.