이 표시 :인스턴스화 된 객체가 보이지 않는 이유는 무엇입니까? 마지막 줄에
// Dynamically add Grid with 8 columns to the StackPanel
Grid grd = new Grid();
ColumnDefinition c0 = new ColumnDefinition();
c0.Width = new GridLength(1, GridUnitType.Star);
. . .
grd.ColumnDefinitions.Add(c0);
. . .
// Add it to the StackPanel
spNufan.Children.Add(grd); // <- ka-pow!
... 난 얻을 "System.NullReferenceException가 개체의 인스턴스로 설정되지 않았습니다 처리되지 않은 메시지 = 개체 참조했다."
그러나 "GRD "라인에서 생성된다
Grid grd = new Grid();
... 및 spNufan (StackPanel에)는 해당 XAML에서이다
<StackPanel Name="spNufan"
Orientation="Vertical">
</StackPanel>
왜 오류입니까?
해당 줄에 중단 점을 넣으십시오. 차례대로 각 개체 (속성 포함) 위에 마우스를 올려 놓습니다. 어느 것이 null인가? 그것을 고정시키는 방법을보십시오. –
Debug.Assert (spNufan! = null);를 추가하면 어떻게됩니까? Debug.Assert (spNufan.Children); 그 후, 예외를 던지기 전에 둘 다? – dgvid
어디에서 (언제)이 코드를 모두 호출합니까? GUI가 아직 생성되지 않은 것 같습니다. –