How can I go to the last column of a DataGrid?

Possible duplicate:
Programmatically displaying a Datagrid column (horizontal scrolling)

I am using WPF with .NET 4 and WPF Toolkit DataGrid. I have a fairly wide datagrid, its first column is frozen, SelectionUnit - Cell.

All I need to do is scroll this datagrid to the last column after the window loads. I tried to "put" my datagrid into a ScrollViewer, but if I use it, the first column of the datagrid will no longer be frozen. I tried using the datagrid ScrollIntoView, but I did not select an element for it, and I cannot select the row to retrieve it (because of my SelectionUnit cell) ...

What can I do to solve my problem? Thanks!

+4
source share
1 answer

for this you just need to use the ScrollIntoView() function on the DataGrid with the first and last columns as follows:

 object row = this.dataGrid1.Items[0]; //Grab the first row DataGridColumn col = this.dataGrid1.Columns[this.dataGrid1.Columns.Count - 1]; //Grab the last column this.dataGrid1.ScrollIntoView(row, col); //Set the view 
+2
source

Source: https://habr.com/ru/post/1385005/


All Articles