Alright so this is going to be hard to explain.
Scenario:
I have a DataGrid defined as follows:
<DataGrid Height="100" Name="test" IsReadOnly="False">
<DataGrid.Columns>
<DataGridTextColumn Header="URL"></DataGridTextColumn>
<DataGridTextColumn Header="PORT"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
It has two headers and I need to add data, I've done a lot of research that suggests using an ObservableCollection since that will fire the DataChanged event.
I can formulate this data with long boring code that probably isn't relevant (you'll see why below).
Problem:
The 200 rows are added but the text itself isn't in the table
Troubleshooting:
I turned on debugging and with screenshots help, you can see there is actual data but it won't insert it into the rows, but it adds the rows.
Relevant Code:
ObservableCollection<Proxy> collection = new ObservableCollection<Proxy>();
collection = GetData(ips,ports);
test.CanUserAddRows = true;
test.ItemsSource = null;
test.ItemsSource = collection;
MessageBox.Show("Done");
NOTE: I added the .ItemSource = null; and then set it equal to the collection as that enabled the rows to show up. I've tried using the suggested: test.DataContext = collection; But, no rows get added at all, and yes just as this test the data is visible in debug mode as being part of the context/itemsource.
UPDATE:
I've tried implementing the following XAML with the same results
<DataGrid Height="100" Name="test" IsReadOnly="False" ItemsSource="{Binding collection}">
<DataGrid.Columns>
<DataGridTextColumn Header="URL" Binding="{Binding ip}"></DataGridTextColumn>
<DataGridTextColumn Header="PORT" Binding="{Binding port}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
Proxy Class:
public class Proxy
{
public string ip;
public string port;
}
UPDATE 2: When adding get and set methods the following was my result: