Here's a sample, which uses DockingManager (a.k.a AvalonDock) from Extended WPF Toolkit.
View model:
Am I missing something?
View model:
public class Person
{
public string Name { get; set; }
public bool CanClose { get; set; }
}
View:<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:local="clr-namespace:WpfApplication2">
<Grid>
<xcad:DockingManager DocumentsSource="{Binding}">
<xcad:DockingManager.Resources>
<DataTemplate DataType="{x:Type local:Person}">
<StackPanel>
<TextBlock Text="Here's person name:"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</xcad:DockingManager.Resources>
<xcad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Content.Name}" />
</DataTemplate>
</xcad:DockingManager.DocumentHeaderTemplate>
<xcad:LayoutRoot>
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutDocumentPane />
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
</Grid>
</Window>
Code-behind:public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new[]
{
new Person { Name = "John" },
new Person { Name = "Mary", CanClose = true },
new Person { Name = "Peter", CanClose = true },
new Person { Name = "Sarah", CanClose = true },
};
}
}
I want to prevent documents from closing via CanClose property in my view model. I've expected, that there must be some style for documents container, so, I'll write something like:<Setter Property="CanClose" Value="{Binding Content.CanClose}"/>
and everything will work. But looks like there's no such style in DockingManager.Am I missing something?