XAML 디자이너 디자인 뷰는 예외가값은 null 일 수 없습니다. 매개 변수 이름 : 키 (만 XAML 디자이너의 디자인 뷰에서 발생)
을 던져졌다
보여줍니다 경우 ArgumentNullException : 값 null 일 수 없습니다.
매개 변수 이름 : 키
스택 트레이스가 (사진 후에 참조)
의 InnerException : 없음
내가 나를 방지 다음 문제에 며칠 동안 고전을 면치 못하고있다영향을받는 모든보기에서 XAML Designe r의 디자인보기를 사용합니다.
어제, 나는 결국은 디자인 타임에 발생하고, 그 일반적인 유형과 데이터 그리드의 ItemsSource 속성 (System.Windows 사이 conflit을 보이기 때문에, 열심히 particulary 추적이 이상한 행동을 분리 관리 .통제 수단).
그래서, 이것은 디자인보기
System.Collections.Generic.Dictionary 2.FindEntry(TKey key) at System.Collections.Generic.Dictionary
2.TryGetValue에서
(TKEY 키, TValue & 값)에서에 표시되는 내용입니다 System.Windows.Controls.DataGridItemAttachedStorage.TryGetValue (개체 항목, DependencyProperty 속성, 개체 & 값) System.Windows.Cont 에서 System.Windows.Controls.DataGridRow.PrepareRow (개체 항목, 데이터 그리드 owningDataGrid)에서 System.Windows.Controls.DataGridRow.SyncProperties에서 rols.DataGridRow.RestoreAttachedItemValue (DependencyObject에 objectWithProperty, DependencyProperty에 속성) (부울 forcePrepareCells) System.Windows에서 System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer에서 System.Windows.Controls.DataGrid.PrepareContainerForItemOverride (DependencyObject에 요소, 개체 항목) (DependencyObject에 컨테이너 개체 항목). Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer (종속성 개체 System.Windows.Controls.VirtualizingStackPanel.InsertContainer에서 컨테이너)에 System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator (INT32 childIndex에, 컨테이너의 UIElement 부울 isRecycled) (INT32 childIndex에, 아이의 UIElement 부울 newlyRealized 부울 isBeforeViewport) at System.Windows.Controls.VirtualizingStackPanel.MeasureChild (IItemContainerGenerator & 발전기, IContainItemStorage & itemStorageProvider, & parentItemStorageProvider는, & parentItem, 부울 & hasUniformOrAverageContainerSizeBeenSet 객체 IContainItemStorage, 더블 & computedUniformOrAverageContainerSize, 더블 & computedUniformOrAverageContainerPixelSize, 부울 & computedAreContainersUniformlySized은 IList & 항목, 객체 & 항목 은 IList & 어린이, Int32 & childIndex에, 부울 & visualOrderChanged, 부울 & isHorizontal, 크기 & childConstraint, 사각형 & 뷰포트, 더블 VirtualizationCacheLength & CACHESIZE, VirtualizationCacheLengthUnit & cacheUnit, 부울 & foundFirstItemInViewport, & firstItemInViewportOffset, 크기 & stackPixelSize, 크기 & stackPixelSizeInViewport, 크기 & 크기 : & stackPixelSizeInCacheBeforeViewportstackLogicalSize, 크기 & stackLogicalSizeInViewport, 크기 & stackLogicalSizeInCacheBeforeViewport, 크기 & stackLogicalSizeInCacheAfterViewport, 부울 & mustDisableVirtualization, 부울 isBeforeFirstItem, 부울 isAfterFirstItem, 부울 isAfterLastItem, 부울 skipActualMeasure, 부울 skipGeneration, 부울 & hasBringIntoViewContainerBeenMeasured, 부울 & hasVirtualizingChildren) at System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl (크기 const raint, Null 허용 previouslyMeasuredOffsets, Nullable`1 &는 lastPagePixelSize, System.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride에서 System.Windows.Controls.VirtualizingStackPanel.MeasureOverride (크기 제약)에서 부울 재 측정) (크기 System.Windows.UIElement.UpdateLayout에서 System.Windows.ContextLayoutManager.UpdateLayout()에서 System.Windows.UIElement.Measure (크기 availableSize) (에서 System.Windows.FrameworkElement.MeasureCore (크기 availableSize)에서 제약))
MyViewModelbase.cs (이것은 내 일반 뷰 모델 기본)
namespace BugProof.ViewModels
{
using System.Collections.Generic;
public class MyViewModelBase<TItem> where TItem : class
{
public List<TItem> Items { get; set; }
public MyViewModelBase() { }
}
}
MyExtendedViewModel.CS (A 문자열 유형에 따라 될 것이 내 확장 된 뷰 모델)
namespace BugProof.ViewModels
{
public class MyExtendedViewModel : MyViewModelBase<string>
{
public MyExtendedViewModel()
{
}
}
}
MainWindow.xaml
MainWindow.xaml.cs를 (MainWindow를의 코드 뒤에
<Window x:Class="BugProof.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:BugProof.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BugProof"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type vm:MyExtendedViewModel}, IsDesignTimeCreatable=False}"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<TextBlock>This is what you should se in the designer</TextBlock>
<!--Try replacing following DataGrid by a ListBox or ListView-->
<DataGrid ItemsSource="{Binding Items}"/>
</StackPanel>
</Window>
)
Complemen TARY 세부 정보 : 하나는 목록 상자에 의해 데이터 그리드 제어를 대체하는 경우 문제가 발생하지 않습니다
- , ListView에 또는 ItemsControl에
- 내가 비주얼 스튜디오 2015 버전 14.0.25431.01 업데이트를 사용하고 있습니다 3
- 프로젝트의 대상은 입니다 .Net Framework 4.5
컬렉션에 정적이 아닌 기본값을 사용하려고 했습니까? 예 :() => 새 목록())? –
반환 값이 null이거나 아닌 경우 get 할 때 테스트해야한다고 생각합니다. – Safe
안녕하세요 @ Geert van Horrik.정적이 아닌 기본값으로 시도 할 때 동일한 결과를 얻습니다. 그러나 List을 List 으로 바꾸면 MyViewModelBase 클래스에 모든 것이 작동합니다. 제네릭 유형과 충돌하는 것 같습니다. –