H
H
Hirty2016-06-14 20:13:26
WPF
Hirty, 2016-06-14 20:13:26

Value outside datagrid window?

var c2 = new DataGridCellInfo(gvData.Items[i], gvData.Columns[1]);
                    var c3 = new DataGridCellInfo(gvData.Items[i], gvData.Columns[2]);
                    var content2 = c2.Column.GetCellContent(c2.Item) as TextBlock;
                    var content3 = c3.Column.GetCellContent(c3.Item) as TextBlock;
                    if (content3 != null && content2 != null)
                    {
                        kj += content3.Text + ":" + content2.Text + "\r\n";
                    }

This is how I write the data that is in the datagrid, but the problem is that it takes only the first 16 that are visible in the window, and the others that need to be scrolled only then it takes the value otherwise null
I have 50 rows, but the window shows 16, the rest are scrollable .
How to make it so that it would perceive all the lines, and not just those that I see.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-06-14
@k1lex

On a good note, you need to change the approach and work with the data source (which C Sharp wrote about ).
The DataGrid is just a display and should not be used as a DataGridView from WinForms.
Create a class. Then create an ObserbvaleCollection from the elements of this class.
Set the itemssource property to the created collection. Enjoy and
write freely. Your hands will be untied. And the search for such solutions will take a mountain of time wasted as a result.

#
#algooptimize #bottize, 2016-06-14
@user004

itemssource

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question