實例在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
您確實需要在此問題和您的「修復」中發佈代碼。例如,你確切地說,你在什麼樣的代碼旁邊沒有設計模式檢查?沒有澄清你的問題和答案都沒有用。 –