If you enable virtualization because the datagrid load time is terrible, then here is the solution:
- disable virtualization
let's assume / call the binding of the data source to the datagrid as "Rows",
public IEnumerable<Row> Rows {get; set;}
"Row" IsVisible , ( ).
, , , , , , * , , . , , , , View.Visibility , ViewModel - .. , . () , ( ), .
private _isVisible = false;
public bool IsVisible
{
get { return _isVisible; }
set
{
if (_isVisible == value)
return;
_isVisible = value;
RaisePropertyChanged(() => IsVisible);
}
}
, datagrid, , , true. , , IsVisible , .
private void OnGridLoaded(object sender, RoutedEventArgs e)
{
if (firstTimeLoad && !_isDataGridLoaded)
{
Task.Factory
.StartNew(() =>
{
foreach (var row in _viewModel.Rows)
ExeOnUi(() => { row.IsVisible = true; });
_firstTimeLoad = false;
})
}
ExeOnUi ( , - , anyControl.Dispatcher.CheckAccess, Microsoft.Practices.ServiceLocator):
static void ExeOnUi (Action action)
{
var srv= ServiceLocator.Current.GetInstance<IDispatchService> ();
if (srv.CheckAccess ())
action.Invoke ();
else
srv.Invoke (action);
}