I have a datagrid, which I scroll to top or there arent enough records to be there a scroll, then ItemContainerGenerator.Status is NotStarted. Why is that? How force ItemContainerGenerator.Status to change status to be ready? Only when I scroll, then ItemContainerGenerator changes a status.
private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) {
if ((sender as ItemContainerGenerator).Status == GeneratorStatus.ContainerGenerated) {
if (obj != null) {
Win.Dispatcher.BeginInvoke(new Action(() => {
Win.SelectedItem = obj;
Win.ScrollIntoView(obj);
}), DispatcherPriority.Render);
}
}
Edit: User can open a few datagrid window. There is a code, which opens DataGrid Window. The bug might be related to ShowAsync
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
var record = GetRecord(); //I get a record from listbox to select in Datagrid
ToolWindowPane win = Package.FindToolWindow(typeOf(Pane), key, false);
if (win!= null) {
MyToolWindow.MyDictionary[record.Name].SelectRecord(record.Name);
return MyToolWindow.ShowAsync(key, false);
}
///... other code, which open window for the first time etc.
}
The window class:
public MyToolWindow() //constructor
{
SelectRecord(record);
}
private void SelectRecord(string record)
{ var obj = LookForRecordToSelect(record);
datagrid.SelectedItem = obj;
datagrid.ScrollIntoView(obj);
}
It might first selection works, because it's defined in constructor