Why did I get this exception in xaml viewer wpf?

I have this in the xaml file:

<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>

In design mode, I always see an error in the xaml file, but I can run it:

System.Reflection.TargetInvocationException . System.RuntimeMethodHandle._InvokeMethodFast (IRuntimeMethodInfo , Object target, Object [] arguments, SignatureStruct & , MethodAttributes methodAttributes, RuntimeType typeOwner) System.RuntimeMethodHandle.InvokeMethodFast( IRuntimeMethodInfo, target, Object [] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, , Object [], CultureInfo, Boolean skipVisibilityChecks) System.Delegate.DynamicInvokeImpl(Object [] args) System.Windows.Threading.ExceptionWrapper.InternalRealCall( callback, Object args, Int32 numArgs) MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen( , , , int32 numArgs, catchHandler)

System.ArgumentNullException . System.RuntimeType.MakeGenericType( [] ) Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeType( ) Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkType.TryGetRuntimeType() Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.EnsureRuntimeType( ) Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.GetRuntimeType( reflectionType) MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeType( reflectionType) Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeType( reflectionType) Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Metadata.IReflectionResolver.GetRuntimeType( reflectionType) MS.Internal.Metadata.ClrType.get_RuntimeMember() MS.Internal.Metadata.ClrMember 1.Microsoft.Windows.Design.Metadata.Reflection.IReflectionMember.get_MemberInfo() at MS.Internal.Metadata.ClrType.Equals(Object obj) at System.Collections.Generic.ObjectEqualityComparer 1.Equals(T x, T y)
System.Collections.Concurrent.ConcurrentDictionary 2.TryGetValue(TKey key, TValue& value) at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.XamlMemberFor[TMember,TXaml](TMember member, Factory 2 factory) MS.Internal.Design.Metadata.Xaml.XamlType.d_7.MoveNext() MS.Internal.Design.Metadata.Xaml.XamlType.d_0.MoveNext() Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.d_7.MoveNext() MS.Internal.VirtualModel.VirtualModelPropertyCollection.d_0.MoveNext() System.Linq.Buffer 1..ctor(IEnumerable 1 ) System.Linq.Enumerable.ToArray [TSource] ( IEnumerable`1) MS.Internal.VirtualModel.VirtualModelPropertyCollection.GetEnumerator() MS.Internal.Designer.PropertyEditing.Model.Properties.ModelPropertyMerger.d__0.MoveNext() MS.Internal.Designer.PropertyEditing.Views.PropertyEntryReader.RedraftEntries(IPropertyViewManager viewManager, , Boolean attachOnly, IEventCodeBehindProxy eventCodeBehindProxy, CategoryList categoryList) MS.Internal.Designer.PropertyEditing.PropertyInspector.UpdateCategories( , Boolean attachOnly, IEntryReader entryReader) MS.Internal.Designer.PropertyEditing.PropertyInspector.RefreshPropertyList(Boolean ) MS.Internal.Designer.PropertyEditing.PropertyInspector.OnSelectionChangedIdle()

  • :

    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; }
    }
    
+3
1

M $ Visual Studio SP1. SP1 , . Microsoft, ?

+1

All Articles