Я создал DockingManager из содержимого AvalonDock в своем проекте, и мой запрос довольно прост: когда я добавляю документ в свою LayoutDocumentPaneGroup, я хочу, чтобы он был активным, выбранным и не только добавлялся в конце LayoutDocumentPaneGroup, но все еще активировалсяна первом документе.
Я пытался реализовать свойство "IsActive" для моего класса documentView, но оно не работает.
Мой док-менеджер в файле xaml определен следующим образом:
<dock:DockingManager DataContext="{Binding DockManagerViewModel}" DocumentsSource="{Binding Documents}" AnchorablesSource="{Binding Anchorables}">
<dock:DockingManager.Resources>
<!-- add views for specific ViewModels -->
<DataTemplate DataType="{x:Type vmdock:SampleDockWindowViewModel}">
<uscontrol:SampleDockWindowView />
</DataTemplate>
</dock:DockingManager.Resources>
<dock:DockingManager.LayoutItemContainerStyle>
<Style TargetType="{x:Type dockctrl:LayoutItem}">
<Setter Property="Title" Value="{Binding Model.Title}" />
<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" />
<Setter Property="CanClose" Value="{Binding Model.CanClose}" />
</Style>
</dock:DockingManager.LayoutItemContainerStyle>
<dock:LayoutRoot>
<dock:LayoutPanel Orientation="Vertical">
<dock:LayoutDocumentPaneGroup>
<dock:LayoutDocumentPane />
</dock:LayoutDocumentPaneGroup>
<dock:LayoutAnchorablePaneGroup>
<dock:LayoutAnchorablePane />
</dock:LayoutAnchorablePaneGroup>
</dock:LayoutPanel>
</dock:LayoutRoot>
</dock:DockingManager>
Мой documentView определен с классом, как показано ниже:
открытый абстрактный класс DockWindowViewModel: BaseViewModel {#region Properties
#region CloseCommand
private ICommand _CloseCommand;
public ICommand CloseCommand
{
get
{
if (_CloseCommand == null)
_CloseCommand = new RelayCommand(call => Close());
return _CloseCommand;
}
}
#endregion
#region IsClosed
private bool _IsClosed;
public bool IsClosed
{
get { return _IsClosed; }
set
{
if (_IsClosed != value)
{
_IsClosed = value;
OnPropertyChanged(nameof(IsClosed));
}
}
}
#endregion
#region CanClose
private bool _CanClose;
public bool CanClose
{
get { return _CanClose; }
set
{
if (_CanClose != value)
{
_CanClose = value;
OnPropertyChanged(nameof(CanClose));
}
}
}
#endregion
#region Title
private string _Title;
public string Title
{
get { return _Title; }
set
{
if (_Title != value)
{
_Title = value;
OnPropertyChanged(nameof(Title));
}
}
}
#endregion
#endregion
public DockWindowViewModel()
{
CanClose = true;
IsClosed = false;
}
public void Close()
{
IsClosed = true;
}