IntelliSense for Data Binding not working
I opened your GitHub project in Visual Studio 2013 and I got the same behavior; no IntelliSense for bindings.
The design data is the key to the binding resolution which is failing, so I recommend this:
- Add your project namespace to your Window element:
xmlns:local="clr-namespace:IntelliSenseForDataBinding"
which can help resolve the location of VM. - Change your
d:DataContext
to use thelocal
namespace instead ofd:Type
, essentially providing the location of the type you're trying to use:d:DataContext="{d:DesignInstance local:MainViewModel, IsDesignTimeCreatable=True}"
- Clean, Build, and Test
Proof:
I know I am late, but Kcvin's answer really helped me a lot and I would like to add that some classes can also use DataType
that helps IntelliSense do its magic.
example:
<DataTemplate x:Key="ItemTemplate" DataType="entities:Item">
<Grid Height="60">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Text=""
Style="{StaticResource MediumIconStyle}"
Margin="{StaticResource XSmallLeftMargin}"
AutomationProperties.Name="List item icon" />
<StackPanel
Grid.Column="1"
Margin="{StaticResource SmallLeftMargin}"
VerticalAlignment="Center">
<TextBlock Style="{StaticResource ListTitleStyle}" Text="{Binding Name}" />
<TextBlock Style="{StaticResource ListSubTitleStyle}" Text="{Binding Description}" />
</StackPanel>
</Grid>
</DataTemplate>
I hope this helps someone in the future.