<Canvas x:Name="Canvas1" >
<Canvas.Resources>
<local:BookList x:Key="bl" BookName="Danieltonight" ISBN="123"/>
</Canvas.Resources>
<TextBox Text="{Binding Path=BookName}" Width="100" Height="50" DataContext="{StaticResource bl}" />
</Canvas>
其中,在XAML中引用隐藏代码中的BookList类时,总是在local:BookList下有蓝色波浪线错误标记,错误提示“The name "BookList" does not exist in the namespace "clr-namespace:WpfAppication42”。该错误在第一次运行后,错误就会消失。
原文地址:http://acadia627.blog.51cto.com/3992605/1729789