Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF DataGrid ScrollIntoView to Top Row

$
0
0

In Visual Studio 2012 I have created a WPF window with a DataGrid that works great.  I am trying to reposition this DataGrid to move forward to a specific row.  I can select the row and use the ScrollIntoView function to display the row, however, the row moving forward is displayed at the bottom of the Grid.  I am not sure how position it such that the row is the top most row in the control. 

When moving backwards in the DataGrid the row seems to be a the top where I prefer it to be displayed.

I even added code to move to the last item and then move backwards as a work-around but that doesn't seem to work either.  Here is my sample code:

            DGrid.SelectedIndex = LastItemIndex;

            DGrid.UpdateLayout();

            DGrid.SelectedIndex = NewPositionIndex;        

            if(DGrid.SelectedItem != null)

            {

                DGrid.ScrollIntoView(DGrid.SelectedItem);

            }

Thanks....


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>