-1
headersDataGrid.ItemsSource
으로 전화하면 응용 프로그램에서 예외가 발생합니다. 누군가 제발 나를 디버깅하고 오류가 무엇인지 확인할 수 있습니까? 감사합니다DataGrid의 ItemSource 오류 : 호출 대상에서 예외가 throw되었습니다.
코드
public static List<Item> getHeaders()
{
Item i1 = new Item();
i1.Label = "TST";
i1.Description = "This header is only for testing";
Item i2 = new Item();
i2.Label = "TS2";
i2.Description = "This is the second header and is used for testing purposes :)";
Item i3 = new Item();
i3.Label = "TS3";
i3.Description = "This is the THIRD header and is used for testing purposes :D";
List<Item> headers = new List<Item>();
headers.Add(i1);
headers.Add(i2);
headers.Add(i3);
return headers;
}
public MainWindow()
{
displayHeaders();
InitializeComponent();
}
/// <summary>
/// The purpose of this method is to display all of the headers
/// </summary>
public void displayHeaders()
{
//List<Item> headers = Database.getHeaders();
// Testing Purposes
List<Item> headers = TestingClass.getHeaders();
// Handle Headers
headersDataGrid.ItemsSource = headers;
}
XML
<Grid Name="grid_headers" Background="Honeydew">
<DataGrid x:Name="headersDataGrid" AutoGenerateColumns="True"></DataGrid>
</Grid>
아 멍청한 실수, thanks @appcoder – AustinT