Data link and reading from DataGrid wpf



  • Hello, I thought I'd get a literate location and reading in and out of the datagrid in the pop. I've been dealing with a very difficult situation and I've decided it in a very bad way.

    (1) I have a connected database, all the names of the fields in the English language, and in the datagrid presentation, I need the names of the fields in Russian.

    (2) I decided to use vare.g. var a = from b in db.clients select new { Имя = b.Name };

    (3) I immediately remembered that I wouldn't have much fun with var, so I made a method that would make a line of paragraph 2 and set it up. datagrid.itemssource = a;

    (4) And on reading, I faced an even bigger problem... I can't read the line in class. datagridrowHe's trying to lead to an anonymous type... But if I make a variable varI'm getting out. object

    (5) I finally use this. ♪ ♪ dynamic changerow = dataGrid.SelectedValue; No mistakes are made, but I think it's awful. Please help me understand how I can literate data so that I can read and record data without special problems. datagridif it's possible without a connection xml♪ Thank you!



  • 1.DataGrid. It's a lot easier to do. I'll have to describe every pole in hand. In principle, a link can be made, as you did in paragraph 3 of the datagrid.ItemSource = a; The right thing to do in the XAML code. a - must be public. The type of column may be different. http://www.wpftutorial.net/datagrid.html I' a page for you.

    <DataGrid AutoGenerateColumns="False" ItemSource = {Binding a} 
     SelectedItem ={Binding selectedItem}>
        <DataGrid.Columns >
            <DataGridTextColumn x:Name="Name" Header="Ваш текст сюда"  Binding="{Binding Path=Name}" HeaderStyle=""></DataGridTextColumn>
    

    1. The correct data link. I advise you that ORM is an EF example, and that MVM is an approach and how everything works in a link.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2