XamlHack: A Better XAMLPad


XamlHack is a little XAML authoring tool which I use in my daily WPF life. whenever I want to author some small pieces of XAML code, I use this tool instead of Visual Studio, becauese this tool is more lightweight and easier to work with when writing some trivial XAML testing code, and the following is some of the features which this version of XamlHack supports:

1. Basic text editing features & syntax highlighting for XAML

Writing a text editor which directly supports syntax highlight is really difficult, fortunately SharpDevelop project already has a decent text editing control, so without reinventing the wheel, I use this control instead, so I can get syntax highlighting, line numbering, folding and unfolding etc at free. I also add the search and replace capability which is essential to any text editor.

2. XAML preview with element tree viewing capability using "Element Tree Explorer"   

In the XAML preview window(aka the "Design" tab shown below), You can examine the definition of the visual tree and logical tree of the root element. I think this feature is very important, since the element tree is a key player in a lot of WPF features for instance resource lookup, property inheritance and routed events etc. By default, the "Element Tree Explorer" is turened off, you can turn it on by checking it from the "View" menu.

3. Examine the default value of DPs using "Property Explorer"

The ability to examine the default value of dependency properties is a vital feature, in particular, when you want to know the default XAML definition for a control's ControlTemplate and Style property, XamlHack has this feature built in, so you don't need to go a long way to use Expression Blend to find out such kind of info, and another plus of this tool is that it enables you to add third party assemblies for examination.

4. Convert BAML to XAML using "Resource Explorer"

I use reflector quite a lot to "reverse engineer" the code written by other poeple, reflector can let you decompile the IL code, but not BAML code, so in order to "reverse engineer" BAML code, I create this tool (at the time of this writing, Reflector already has this feature.)

5. Last but not least, peculiar error warning.

When your XAML code contains some errors, XamlHack will show you a hilarious error warning message in "Design" tab, and when you click the message, it will turn you back to your xaml code, and directly highlight the source of error for you.

If XamlHack and the features it provides make some sense to you, you can download it here and have a try on it, any feedback and suggestions are greatly appreciated.

Attachment: XamlHack.zip

Ribbon Style Ⅱ


As a follow-up to my previous post, I continue my work on creating ribbon styled controls, It seems that someone else has already take on the adventure, and what he has created is really cool indeed.

Anyway, the following screenshot demonstrates the current progress I am at:

Currently I cannot upload the source to my server, I promise when it get fixed, I will update this post to include the download link.

Edit: Source is uploaded, you can download the vs project here.

How To Reference Nested Types In XAML?


This is actually an undocumented trick, but it really works:

namespace ReferenceNestedTypeDemo
    public class MyClass
        public enum MyEnum { Value1, Value2, Value3 };

ComboBoxItem Tag="{x:Static app:MyClass+MyEnum.Value1}">Value 1</ComboBoxItem>
ComboBoxItem Tag="{x:Static app:MyClass+MyEnum.Value2}">Value 2</ComboBoxItem>


Ribbon Style Ⅰ


Recently, I have some fun spicing up the standard WPF controls to make them looks like the flashy ribbon style which is available in the Office 2007. I'm so stunned by how easy you can do it in WPF using styling and control templating:

For those of you who are interested in this, you can download source from here.