为什么我在wpf的xaml查看器中出现此异常?
我在xaml文件中有以下内容:为什么我在wpf的xaml查看器中出现此异常?,wpf,Wpf,我在xaml文件中有以下内容: <Window x:Class="TestTool.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:RecoConfigTool="clr-namespace:TestTool" Title="Window
<Window x:Class="TestTool.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:RecoConfigTool="clr-namespace:TestTool" Title="Window1" Height="300" Width="300">
<Grid>
<ItemsControl ItemsSource="{Binding Parents}">
</ItemsControl>
</Grid>
<Window.Resources>
<DataTemplate DataType="{x:Type RecoConfigTool:Parent}">
<StackPanel>
<TextBox Text="{Binding Name}"/>
<ListView ItemsSource="{Binding Childs}"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="{x:Type RecoConfigTool:Child}">
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding Name}"/>
<TextBox>,</TextBox>
<TextBox Text="{Binding Age}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
</Window>
- 这是Visual Studio SP1 bug的一个问题。卸载SP1并在为我解决它之后愉快地工作。这是非常不令人满意的,也是微软礼服上的另一个耻辱污点,但是有什么选择呢?您认为
RecoConfigTool:Parent
和RecoConfigTool:Child
看起来像什么?它们是泛型类吗?@sixlettvariables:更新了代码是否安装了VS2k10 SP1。是的,它是VS2K10 SP1。我认为卸载SP1不应该是一个解决方案,因为我需要SP1。还有其他解决办法吗?提前感谢。在我的案例中,这个问题在FluentNHibernate的某个版本中再次出现。另一种让它恢复工作的方法是获取最新的FNH源代码并自己编译。不同的装配,工作良好。不知道VS出了什么问题,因为我甚至没有从该库调用任何方法,只是引用它导致了崩溃。正如你所看到的:没有答案,只是不同的问题。。。
public class Parent
{
public string Name { get; set; }
public List<Child> Childs { get; set; }
}
public class ParentFactory
{
public List<Parent> Parents { get; set; }
public ParentFactory()
{
var child1 = new Child{Name="Peter", Age=10, Married = true};
var child2 = new Child{ Name = "Mary", Age = 9, Married = false };
var child3 = new Child{ Name = "Becky", Age = 12, Married = false };
var parent1 = new Parent{Name="Adam", Childs = new List<Child>(){child1, child2}};
var parent2 = new Parent{Name="Kevin", Childs = new List<Child>(){child3}};
Parents = new List<Parent>{parent1, parent2};
}
}
public class Child
{
public string Name { get; set; }
public int Age { get; set; }
public bool Married { get; set; }
}