Quantcast
Channel: AvalonDock
Viewing all articles
Browse latest Browse all 2690

Created Unassigned: [Version 2] NullReferenceException when closing anchorable [16494]

$
0
0
When I attempt to close an anchorable by pushing the close button, I am receiving a NullReferenceException. The exception is coming from the close method within LayoutContent.cs.


```
public void Close()
{
var root = Root;
var parentAsContainer = Parent as ILayoutContainer;
parentAsContainer.RemoveChild(this);
if (root != null)
root.CollectGarbage();

OnClosed();
}
```

From what I'm seeing, Parent is null.

I'm not sure if it is related, but when BeforeInsertAnchorable is called in my LayoutStrategy, the ILayoutContainer argument is null as well.

```
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
{...}
```


Layout:

```
<ad:DockingManager Name="dockingManager"
Grid.Row="1" Margin="0"
shell:WindowChrome.IsHitTestVisibleInChrome="True"
DocumentsSource="{Binding Items}"
AnchorablesSource="{Binding Tools}"
ActiveContent="{Binding CurrentActiveItem, Mode=TwoWay}">
<ad:DockingManager.LayoutItemTemplate>
<DataTemplate>
<ContentControl cal:View.Model="{Binding}" IsTabStop="False" />
</DataTemplate>
</ad:DockingManager.LayoutItemTemplate>
<ad:DockingManager.LayoutItemContainerStyleSelector>
<f:PanesStyleSelector>
<f:PanesStyleSelector.ToolStyle>
<Style TargetType="{x:Type ad:LayoutAnchorableItem}">
<Setter Property="ContentId" Value="{Binding Model.ContentId}" />
<Setter Property="Title" Value="{Binding Model.DisplayName, Mode=OneWay}" />
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" />
<Setter Property="IconSource" Value="{Binding Model.IconSource, Converter={StaticResource NullableValueConverter}}" />
<Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}" />
<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Style>
</f:PanesStyleSelector.ToolStyle>
<f:PanesStyleSelector.DocumentStyle>
<Style TargetType="{x:Type ad:LayoutItem}">
<Setter Property="ContentId" Value="{Binding Model.ContentId}" />
<Setter Property="Title" Value="{Binding Model.DisplayName, Mode=OneWay}" />
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" />
<Setter Property="IconSource" Value="{Binding Model.IconSource, Converter={StaticResource NullableValueConverter}}" />
<Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}" />
</Style>
</f:PanesStyleSelector.DocumentStyle>
</f:PanesStyleSelector>
</ad:DockingManager.LayoutItemContainerStyleSelector>
<ad:DockingManager.LayoutUpdateStrategy>
<f:LayoutStrategy />
</ad:DockingManager.LayoutUpdateStrategy>
<ad:LayoutRoot>
<ad:LayoutPanel Orientation="Horizontal">
<ad:LayoutDocumentPane/>
</ad:LayoutPanel>
</ad:LayoutRoot>
</ad:DockingManager>
```

Viewing all articles
Browse latest Browse all 2690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>