0
I have a datagrid
with evaluations whose first column is PATIENT NAME. However, when it comes to placing Binding Paciente.Nome
it gives error. Within evaluation there is a patient object.
DATAGRID CODE
<DataGrid x:Name="DataGridPSc" Background="White" HorizontalAlignment="Center" IsReadOnly="True" Grid.Column="0" Grid.Row="1" Margin="0,10,0,0" Width="850" MouseDoubleClick="DataGridPSC_OnMouseDoubleClick">
<DataGrid.Columns>
<DataGridTextColumn Header="Id" Width="100" Binding="{Binding Path=Id}" Visibility="Hidden"/>
<DataGridTextColumn Header="Paciente" Width="*" Binding="{Binding Path= Paciente.Nome}"/>
<DataGridTextColumn Header="Status" Width="*" Binding="{Binding Path=Status}"/>
<DataGridTextColumn Header="Data da Avaliação" Width="125" Binding="{Binding Path=DataAvaliacao, StringFormat=\{0:dd/MM/yyyy\}}"/>
</DataGrid.Columns>
DATAGRID COMPLETION CODE
DataGridPSc.Items.Clear(); ;
var avaliacoes = ManagerAvaliacaoPSc.Avaliacoes().OrderByDescending(a => a.DataAvaliacao);
foreach (var a in avaliacoes)
{
DataGridPSc.Items.Add(a);
}
MANAGER EVALUATION PSC
public static List<Avaliacao_Psc> Avaliacoes()
{
try
{
using (var db = new TrabalhoDataContext())
{
return db.Avaliacao_Pscs.OrderByDescending(a => a.DataAvaliacao).ToList();
}
}
catch (Exception ex)
{
throw new Exception("Erro ao tentar carregar as avaliações: " + ex);
}
}
IMAGE WITH THE ERROR
Post the code where the error occurs.
– ramaral
@ramaral occurs at the time the form with the datagrid is loaded, that is, in onload, which contains the fill code of the datagrid that is in this post
– Leomar de Souza
I decided to leave for a plan b. I created a view doing the Inner Join between patient and evaluation. Solved the problem so far.
– Leomar de Souza