1
I’m making the population of a Datagrid, but I don’t know why you’re not showing.
Result:
Only empty lines are returned.
Fiscalizacao.Cs
public class Fiscalizacoes
{
private String Concessionaria { get; set; }
private String Municipio { get; set; }
private String Sistemas { get; set; }
private DateTime DataInicio { get; set; }
private DateTime DataFim { get; set; }
private String Status { get; set; }
public Fiscalizacoes()
{
}
public Fiscalizacoes(String concessionaria, String municipio, String sistemas, DateTime datainicio,
DateTime datafim, String status)
{
Concessionaria = concessionaria;
Municipio = municipio;
Sistemas = sistemas;
DataInicio = datainicio;
DataFim = datafim;
Status = status;
}
}
populaGrid()
private static IEnumerable<Fiscalizacoes> popularGrid()
{
var listaFiscalizacao = new List<Fiscalizacoes>
{
new Fiscalizacoes("SABESP", "São Paulo", "Abastecimento Água", new DateTime(2014, 12, 1),
new DateTime(2014, 12, 10), "Não Respondido"),
new Fiscalizacoes("Mairinque", "Taubaté", "Esgotamento Sanitário", new DateTime(2014, 12, 1),
new DateTime(2014, 12, 10), "Respondido"),
new Fiscalizacoes("Foz Gertrudes", "São José dos Campos", "Esgotamento Sanitário", new DateTime(2014, 12, 1),
new DateTime(2014, 12, 10), "Transmitido")
};
return listaFiscalizacao;
}
XAML
<DataGrid x:Name="dataGridFiscalizacoes" ItemsSource="{Binding listaFiscalizacao}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Concessionária" Binding="{Binding Concessionaria}" />
<DataGridTextColumn Header="Município" Binding="{Binding Municipio}" />
<DataGridTextColumn Header="Sistemas" Binding="{Binding Sistemas}" />
<DataGridTextColumn Header="Data Início" Binding="{Binding DataInicio}" />
<DataGridTextColumn Header="Data Fim" Binding="{Binding DataFim}" />
<DataGridTextColumn Header="Status Checklist" Binding="{Binding Status}" />
</DataGrid.Columns>
</DataGrid>
window
public ChecklistListagem(InicioWindow w)
{
InitializeComponent();
this.w = w;
dataGridFiscalizacoes.ItemsSource = popularGrid();
}
At some event you are associating the Itemsource?
dataGridFiscalizacoes.ItemsSource = popularGrid();
– Diego Zanardo
@Diegozanardo Yes, I’m associating. I forgot to put...
– Leonardo
Have you tried to change the scope of your properties to public?
– Jônatas Hudler
@Jonathan shudler was just that!
– Leonardo