0
동적으로 목록 상자를 만들었지 만 이제는 WPF를 통해 모든 것을 엄격하게 처리하고 있습니다. 왜 .. 나에게 맞는 것 같아서 내가 뭔가를 놓친 것 같아?Listbox 내 StackPanels의 자식에 액세스 할 수없는 것 같습니다
내가지고있어 오류가
WPF 코드 "개체 참조가 개체의 인스턴스로 설정되지 않았습니다"입니다 :
<ListBox x:Name="ListBoxT10">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBox FontSize="14" Text="" Width="120"/>
<TextBox FontSize="14" Text="" Width="40" MaxLength="3"/>
<TextBox FontSize="14" Text="" Width="413"/>
</StackPanel>
</ListBoxItem>
...a bunch of the same listboxitems...
C# 코드 :
int a = 0;
foreach (var item in ListBoxT10.Items)
{
StackPanel tempStackPanel = item as StackPanel;
Console.WriteLine(tempStackPanel.Children.Count); //this even errors.. i guess it's not finding the children
string pName = (tempStackPanel.Children[0] as TextBox).Text; //error
string tri = (tempStackPanel.Children[1] as TextBox).Text; //error
string stats = (tempStackPanel.Children[2] as TextBox).Text; //error
편집 : 그것은 ListBoxT10.Items의 항목이 실제로 "ListBoxItem" 's입니다. 그러나 이제는 listboxitems의 하위 항목을 가져올 수 없기 때문입니다. ugh = [