我正在尝试使用带有 WPF 的 AvalonDock 动态添加选项卡,但我无法做到。
你有什么线索错了吗?
动态添加标签的代码
public DockView()
{
MyDocuments = new ObservableCollection<DocumentContent>();
InitializeComponent();
}
public void CreateView()
{
string baseDocTitle = "MyDocument";
int i = 1;
string title = baseDocTitle + i.ToString();
while (dockManager.Documents.Any(d => d.Title == title))
{
i++;
title = baseDocTitle + i.ToString();
}
MyDocuments.Add(new DocumentContent() { Title = title });
}
public ObservableCollection<DocumentContent> MyDocuments { get; private set; }
XAML 代码
<Menu>
<MenuItem Header="Documents">
<MenuItem Click="MenuItem_Click" Header="Create New" />
</MenuItem>
</Menu>
<ad:DockingManager x:Name="dockManager" Grid.Row="2"
DocumentsSource="{Binding MyDocuments}">
<ad:ResizingPanel>
<ad:DocumentPane />
</ad:ResizingPanel>
</ad:DockingManager>