If I set Window.DataContext in code behind, everything is ok:
public MainWindow()
{
InitializeComponent();
DataContext = new MainViewModel();
}
But if I set Window.DataContext in xaml instead, CanClose setter of LayoutItem Style will not work, the cross button will show even if I set CanClose to false in style:
<Window.DataContext>
<local:MainViewModel></local:MainViewModel>
</Window.DataContext>
...
<DockingManager.LayoutItemContainerStyleSelector>
<views:PanesStyleSelector>
<views:PanesStyleSelector.ToolStyle>
<Style TargetType="{x:Type LayoutAnchorableItem}">
<Setter Property="Title" Value="{Binding Model.Name}" />
<Setter Property="CanClose" Value="True" />
<Setter Property="CloseCommand" Value="{Binding Model.CmdClose}" />
<Setter Property="Visibility"
Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}" />
<Setter Property="ContentId" Value="{Binding Model.ViewType}" />
</Style>
</views:PanesStyleSelector.ToolStyle>
<views:PanesStyleSelector.FileStyle>
<Style TargetType="{x:Type LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Name}" />
<Setter Property="CanClose" Value="False" />
<Setter Property="ContentId" Value="{Binding Model.ViewType}" />
</Style>
</views:PanesStyleSelector.FileStyle>
</views:PanesStyleSelector>
</DockingManager.LayoutItemContainerStyleSelector>
Here is my demo project and a snapshot of this bug.

BugDemo.zip
If I set Window.DataContext in code behind, everything is ok:
But if I set Window.DataContext in xaml instead, CanClose setter of LayoutItem Style will not work, the cross button will show even if I set CanClose to false in style:
Here is my demo project and a snapshot of this bug.
BugDemo.zip