实例在XAML代码中,我得到一个错误说服力不能创建的 实例此AllEmployeeViewModel类文件,实际上这个类文件存在于溶液中的文件夹,当我型可控硅:在intellsene显示我类文件不能创建XAML在Silverlight 4.0
<UserControl.Resources>
<scr:AllEmployeeViewModel x:Key="empName"></scr:AllEmployeeViewModel>
</UserControl.Resources>
<Grid x:Name="MainGrid" Background="White" Width="400"
Height="407" DataContext="{Binding Source={StaticResource empName}}" >
<Grid x:Name="grdAllEmp" DataContext="{Binding Path=EmployeeClass}">
<sdk:DataGrid AutoGenerateColumns="True" Height="274"
HorizontalAlignment="Left" Margin="8,8,0,0"
Name="dgEmployee" VerticalAlignment="Top" Width="385"
ItemsSource="{Binding}"/>
<Button Content="Get All Employees" Height="23"
HorizontalAlignment="Left" Margin="12,288,0,0"
Name="btnAllEmplloyees" VerticalAlignment="Top" Width="381"
Command="{Binding Path=DataContext.GetEmployees,ElementName=MainGrid}"/>
</Grid>
我试图绑定到数据网格,如果我忽略编译时错误和运行其给未发现的错误的关键。
请让我知道你知道solutionif,在这个问题上的工作从过去的2天
任何帮助将是巨大的 感谢。
解决方案:InitializeComponent(); if(!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) { //抛出异常的代码 } – happysmile
您确实需要在此问题和您的“修复”中发布代码。例如,你确切地说,你在什么样的代码旁边没有设计模式检查?没有澄清你的问题和答案都没有用。 –