I am saving and re-loading open documents when the application ends and starts and I found no way to cancel re-loading a specific file when the application starts. Cancelling should be possible, because a file may not exist on application start or there may be any kind of error signalled by the viewmodel load function.
What I miss is a return parameter that lets the sender know that this item is to be skipped for re-load (as outline further below in the code).
I was able to verify this also with the AvalonDock.MVVMTestApp through:
- Loading a file
- Saving the layout
- Exit AvalonDock.MVVMTestApp
- Rename the file (in Windows files system) that I previously loaded in AvalonDock.MVVMTestApp
- Re-start AvalonDock.MVVMTestApp
Issue:
There was an empty document dock control (just a tab item but no content)
In the current build 97076 saving and re-loading the layout does no longer
work with the AvalonDock.MVVMTestApp (even without renaming the file) -
I see that the LayoutSerializationCallback is commented out(?).
Re-loading non-existing file cannot be cancelled
------------------------------------------------------------------------------
var layoutSerializer = new XmlLayoutSerializer(mainWin.dockManager);
layoutSerializer.LayoutSerializationCallback += (s, e) =>
{
if (e.Model.ContentId == FileStatsViewModel.ToolContentId)
e.Content = Workspace.This.FileStats;
else
if (e.Model.ContentId == RecentFilesViewModel.ToolContentId)
e.Content = Workspace.This.RecentFiles;
else
{
if (workSpace.Config.ReloadOpenFilesOnAppStart == true)
{
if (!string.IsNullOrWhiteSpace(e.Model.ContentId) && System.IO.File.Exists(e.Model.ContentId))
{
e.Content = Workspace.This.Open(e.Model.ContentId);
}
// else
// e.Cancel = true;
}
}
};
layoutSerializer.Deserialize(layoutFileName);
------------------------------------------------------------------------------
What I miss is a return parameter that lets the sender know that this item is to be skipped for re-load (as outline further below in the code).
I was able to verify this also with the AvalonDock.MVVMTestApp through:
- Loading a file
- Saving the layout
- Exit AvalonDock.MVVMTestApp
- Rename the file (in Windows files system) that I previously loaded in AvalonDock.MVVMTestApp
- Re-start AvalonDock.MVVMTestApp
Issue:
There was an empty document dock control (just a tab item but no content)
In the current build 97076 saving and re-loading the layout does no longer
work with the AvalonDock.MVVMTestApp (even without renaming the file) -
I see that the LayoutSerializationCallback is commented out(?).
Re-loading non-existing file cannot be cancelled
------------------------------------------------------------------------------
var layoutSerializer = new XmlLayoutSerializer(mainWin.dockManager);
layoutSerializer.LayoutSerializationCallback += (s, e) =>
{
if (e.Model.ContentId == FileStatsViewModel.ToolContentId)
e.Content = Workspace.This.FileStats;
else
if (e.Model.ContentId == RecentFilesViewModel.ToolContentId)
e.Content = Workspace.This.RecentFiles;
else
{
if (workSpace.Config.ReloadOpenFilesOnAppStart == true)
{
if (!string.IsNullOrWhiteSpace(e.Model.ContentId) && System.IO.File.Exists(e.Model.ContentId))
{
e.Content = Workspace.This.Open(e.Model.ContentId);
}
// else
// e.Cancel = true;
}
}
};
layoutSerializer.Deserialize(layoutFileName);
------------------------------------------------------------------------------