Visual Studio 2013 brings IntelliSense for Data Binding to XAML editor

One of the better improvements in Visual Studio 2013 is IntelliSense for data binding in XAML editor. The improvement is described in this blog post. Very nice. But what article fails to mention is how does one get that mystical d namespace. In face, it is not exactly easy to find the proper declaration.

After some googling around I have found this declaration:

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

Then I tried applying a d:DataContext to the first element on the default window template – Grid, like:

<Grid d:DataContext="{d:DesignInstance Type=local:Tubo}">
    <TextBlock Text="{Binding Xul}"
</Grid>

That is supposed to work, but it doesn't (I have a simple class Tubo with a single property Xul in local namespace). Instead of compiling it was throwing this error at me:

The property 'DataContext' must be in the default namespace or in the element namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

Yeah, right. After some more googling I found that I had to add another namespace and a ignore property to the mix:

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"

These two lines did the trick, error was gone, the project compiled and IntelliSense was alive.

Here is my whole XAML:

<Window x:Class="WpfApplication73.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:WpfApplication73"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid d:DataContext="{d:DesignInstance Type=local:Tubo}">
        <TextBlock Text="{Binding Xul}"
    </Grid>
</Window>

Hopefully this post will spare some time for others trying to achieve the IntelliSense…