Good day. I can not bind the property of an entity into a datagrid column.
Student entity with Price and LessonLength properties ported from DB (DataBase First). Created your PriceForHour property in the following way:

public partial class Student { public double PriceForHour { get { return this.Price / this.LessonLength; } } } 

Properties are bind to data in xaml as follows

  <DataGrid AutoGenerateColumns="False" HorizontalAlignment="Stretch" Name="studentsGrid" VerticalAlignment="Stretch" CanUserResizeColumns="True" IsReadOnly="True" Margin="0,0,81,0"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Surname}" Header="Фамилия" /> <DataGridTextColumn Binding="{Binding Name}" Header="Имя"/> <DataGridTextColumn Binding="{Binding ClassNumber}" Header="Класс"/> <DataGridTextColumn Binding="{Binding Street.Street_Name}" Header="Улица" /> <DataGridTextColumn Binding="{Binding HouseNumber}" Header="Дом" /> <DataGridTextColumn Binding="{Binding ApartmentNumber}" Header="Квартира" /> <DataGridTextColumn Binding="{Binding PriceForHour}" Header="Цена в час" /> </DataGrid.Columns> </DataGrid> 

In .cs

  studentsGrid.ItemsSource = ((App)App.Current).currentTeacher.Students; 

Everything is displayed, except for PriceForHour, in the debug mode the student can see that the field is filled in correctly.
What am I doing wrong? Thank you in advance.

  • You should not be attached to the model at all. The database does not have the right to run in a UI stream. - VladD
  • Could you write the name of the technology or pattern by which you should organize work with the database and binding? Thanks in advance - AAPrigorodov
  • Well, the idea is MVVM. - VladD

0