Hello,
I am currently using Avalondock 2.0 with the mvvm pattern.
It seems that when you remove an element present in your datasource, the DockManager does not remove the element from the root panel.
Ex:
This is how I bind my sources.
```
<xcad:DockingManager x:Name="dockManager"
DocumentsSource="{Binding Workspace.Tools}"
AnchorablesSource="{Binding Workspace.Informations}"
ActiveContent="{Binding ActiveDocument, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}" >
```
-Tools & Informations are ObservableCollection<T>
How my content is bind
```
<Selector:PanesTemplateSelector>
<Selector:PanesTemplateSelector.ToolViewTemplate>
<DataTemplate>
<GroupBox Content="{Binding UserControl, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" />
</DataTemplate>
</Selector:PanesTemplateSelector.ToolViewTemplate>
```
Then how I bind my CloseCommand.
```
<Selector:PanesStyleSelector>
<Selector:PanesStyleSelector.ToolStyle>
<Style TargetType="{x:Type xcad:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
</Style>
</Selector:PanesStyleSelector.ToolStyle>
```
Now when I click on the 'X' button, I will remove my tool panel from my ObservableCollection<T> like this.
```
internal void Close(PaneViewModel fileToClose)
{
if (fileToClose.IsDirty)
{
///
}
var workingScreen = fileToClose as ToolViewModel;
if (workingScreen != null)
{
Tools.Remove(workingScreen);
}
}
```
I tried something I put a timer on my workingScreen and I could noticed that:
- Event if the WorkingScreen is removed from the OBSC<T> the timer is still working.
- The UserControl present in the OBSC<T> is never collected.
Is there a way to ask to the DockManager to remove the Child related the ClosingScreen when I remove it from the ObservableCollection<>?
I do not have access to the DockPanelRoot, I am working in MVVM.
Regards,
Comments: ** Comment from web user: pixipix **
I am currently using Avalondock 2.0 with the mvvm pattern.
It seems that when you remove an element present in your datasource, the DockManager does not remove the element from the root panel.
Ex:
This is how I bind my sources.
```
<xcad:DockingManager x:Name="dockManager"
DocumentsSource="{Binding Workspace.Tools}"
AnchorablesSource="{Binding Workspace.Informations}"
ActiveContent="{Binding ActiveDocument, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}" >
```
-Tools & Informations are ObservableCollection<T>
How my content is bind
```
<Selector:PanesTemplateSelector>
<Selector:PanesTemplateSelector.ToolViewTemplate>
<DataTemplate>
<GroupBox Content="{Binding UserControl, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" />
</DataTemplate>
</Selector:PanesTemplateSelector.ToolViewTemplate>
```
Then how I bind my CloseCommand.
```
<Selector:PanesStyleSelector>
<Selector:PanesStyleSelector.ToolStyle>
<Style TargetType="{x:Type xcad:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}"/>
<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
</Style>
</Selector:PanesStyleSelector.ToolStyle>
```
Now when I click on the 'X' button, I will remove my tool panel from my ObservableCollection<T> like this.
```
internal void Close(PaneViewModel fileToClose)
{
if (fileToClose.IsDirty)
{
///
}
var workingScreen = fileToClose as ToolViewModel;
if (workingScreen != null)
{
Tools.Remove(workingScreen);
}
}
```
I tried something I put a timer on my workingScreen and I could noticed that:
- Event if the WorkingScreen is removed from the OBSC<T> the timer is still working.
- The UserControl present in the OBSC<T> is never collected.
Is there a way to ask to the DockManager to remove the Child related the ClosingScreen when I remove it from the ObservableCollection<>?
I do not have access to the DockPanelRoot, I am working in MVVM.
Regards,
Comments: ** Comment from web user: pixipix **
Sorry for the inconvenient.
My timer was causing the memory leak :/