wpfdatagrid - Is ScrollIntoView synchronized in virtualstackpannel (Especially in WPF DataGrid)? -


we have problem focus cell of datagrid after data of bounded collection has refreshed. example set filter collection , want refocus stored cell of stored column.

is true think call scrollintoview synchronized means after call our desired row , cell created , can set focus? (again means after call scrollintoview , true think itemsgenerator finished work , can surly find our desired cell)

$

   //set filter of datagrid collection datagrid_standard.scrollintoview(rownumber,cellnumber); //we sure our desired cell created     datagridrow row =           (datagridrow)datagrid_standard.itemcontainergenerator.containerfromindex(index);     if (row == null)     {         // may virtualized, bring view , try again         datagrid_standard.scrollintoview(datagrid_standard.items[index]);         row = (datagridrow)datagrid_standard.itemcontainergenerator.containerfromindex(index);     }           datagridcellspresenter presenter = getvisualchild<datagridcellspresenter>(rowcontainer);          // try cell may possibly virtualized         datagridcell cell = (datagridcell)presenter.itemcontainergenerator.containerfromindex(column);              // try bring view , retreive cell             datagrid_standard.scrollintoview(rowcontainer, datagrid_standard.columns[column]);             cell = (datagridcell)presenter.itemcontainergenerator.containerfromindex(column);             cell.focus(); 

related

here's datagrid selection changed event handler moves virtualized row view , sets focus row. works me:

        private void datagrid_selectionchanged(object sender, selectionchangedeventargs e)     {         datagrid dg = (datagrid)sender;         if (dg.selecteditem == null) return;         dg.scrollintoview(dg.selecteditem);          datagridrow dg_row = (datagridrow)dg.itemcontainergenerator.containerfromitem(dg.selecteditem);         if (dg_row == null) return;        dg_row.movefocus(new traversalrequest(focusnavigationdirection.next));      } 

edit: using dg_row.movefocus method had undesriable effect (a checkbox column required 2 clicks set instead of one) , worked better me use

dg_row.focus(); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -