I modified the AvalonDock.MVVMTestApp to have a menu option to create ToolViewModels and add them to the ToolsPane (and to the AnchorablesSource collection). This is the core of the code that does it:
private void OnNewTool(object parameter)
{
_tools.Add(new ToolViewModel("SomeName"));
ActiveDocument = _tools.Last();
}
That works fine. But what I was looking for was notification when a tool window closed.
So I added this to the PanesStyleSelector.ToolStyle:
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
This works perfectly for the FileViewModel. So I figured it would work for the tool side as well.
But when I close the tool item, the command does not fire. Also setting CanExecute to False does not stop the closing.
Note: When I debug the binding with PresentationTraceSources.TraceLevel=High, it shows that the binding is successful.
Comments: ** Comment from web user: MichaelTR **
private void OnNewTool(object parameter)
{
_tools.Add(new ToolViewModel("SomeName"));
ActiveDocument = _tools.Last();
}
That works fine. But what I was looking for was notification when a tool window closed.
So I added this to the PanesStyleSelector.ToolStyle:
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
This works perfectly for the FileViewModel. So I figured it would work for the tool side as well.
But when I close the tool item, the command does not fire. Also setting CanExecute to False does not stop the closing.
Note: When I debug the binding with PresentationTraceSources.TraceLevel=High, it shows that the binding is successful.
Comments: ** Comment from web user: MichaelTR **
ok, I found the problem.
_tools has to be of type ObservableCollection, that's all.