Hi Radu,
The DataContext property is not a reliable way to pass a context down to the content of a DocumentWindow or ToolWindow. Mainly because DocumentWindow and ToolWindow are not a visual parent/ancestor of it's content. Instead, these types are only visually responsible for their associated tab, or in the case of standard MDI, their window. The content of the selected window is displayed by an associated container, such as TabbedMdiContainer, RaftedDocumentWindowContainer, or ToolWindowContainer.
Because the DocumentWindow and ToolWindow are not visual parents/ancestors of their content, their DataContext is not generally inherited down. Instead the DataContext of the container is inherited by the content. But it appears in the case of auto-hidden windows, the DataContext of the tool window is inherited.
In the following code, it may be expected that the TextBlock would display the string represented by StringValue (assuming the DataContext has been properly set on the associated Window/Page):
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
...
<docking:DockSite>
<docking:DockSite.AutoHideLeftContainers>
<docking:ToolWindowContainer>
<docking:ToolWindow Title="DataContext Test" DataContext="{Binding StringValue}">
<TextBlock Text="{Binding}" />
</docking:ToolWindow>
</docking:ToolWindowContainer>
</docking:DockSite.AutoHideLeftContainers>
...
</docking:DockSite>
The above code may work initially, but the DataContext on the ToolWindow will get cleared when it is pinned or docked. As a result the TextBlock will no longer display the proper string.
Rewriting the code above, like so will correctly display the approriate string in the TextBlock in all instances:
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
...
<docking:DockSite>
<docking:DockSite.AutoHideLeftContainers>
<docking:ToolWindowContainer>
<docking:ToolWindow Title="DataContext Test">
<Grid DataContext="{Binding StringValue}">
<TextBlock Text="{Binding}" />
</Grid>
</docking:ToolWindow>
</docking:ToolWindowContainer>
</docking:DockSite.AutoHideLeftContainers>
...
</docking:DockSite>
The DataContext is now set on the root element of the content, instead of the ToolWindow. The Grid can inherit it's DataContext from the container or the tool window and still properly resolve it's binding.
We've added a troubleshooting topic on this matter in our documentation.