Liens utiles
|
<dxdo:DockLayoutManager>
<dxdo:LayoutGroup>
<dxdo:LayoutPanel Caption="Menu" ItemWidth="150">
</dxdo:LayoutPanel>
<dxdo:DocumentGroup ClosePageButtonShowMode="InAllTabPageHeaders"
DestroyOnClosingChildren="False">
<dxdo:DocumentPanel Caption="Document 1">
<RichTextBox/>
</dxdo:DocumentPanel>
</dxdo:DocumentGroup>
</dxdo:LayoutGroup>
<dxdo:DockLayoutManager.AutoHideGroups>
<dxdo:AutoHideGroup DockType="Bottom">
<dxdo:LayoutPanel Caption="Output" ItemHeight="150">
</dxdo:LayoutPanel>
</dxdo:AutoHideGroup>
</dxdo:DockLayoutManager.AutoHideGroups>
</dxdo:DockLayoutManager>
|
|
// sélectionner un DocumentPanel
DockLayoutManager.DockController.Activate(DocumentPanel);
|
DocumentGroup et ItemsSource
Cause l'erreur « Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead. » lors de la fermeture d'un DocumentPanel avec la croix en haut à droite.
Solution: mettre l'ItemsSource sur le DockLayoutManager.
MainWindow.xaml
|
<Window.Resources>
<Style TargetType="{x:Type dxdo:DocumentPanel}">
<Setter Property="Caption" Value="{Binding Caption}"/>
</Style>
</Window.Resources>
<dxdo:DockLayoutManager x:Name="dlm" ItemsSource="{Binding Path=DocumentList}">
<dxdo:LayoutGroup>
<dxdo:DocumentGroup x:Name="dg"
ClosePageButtonShowMode="InAllTabPageHeaders"
DestroyOnClosingChildren="False" />
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
|
MainWindow.xaml.cs
|
if (dg.Items.Select(i => i.Caption).Contains(e.AddedItems[0]))
{
dlm.DockController.Activate(dg.Items.First(i => i.Caption.Equals(e.AddedItems[0])));
}
|
MainWindowVM
|
public virtual ObservableCollection<DocumentPanelInfo> DocumentList { get; set; }
protected void OnSelectedMenuChanging(string newValue)
{
if (!DocumentList.Select(d => d.Caption).Contains(newValue))
{
DocumentList.Add(new DocumentPanelInfo() { Caption = newValue });
}
else if (DocumentList.Where(d => d.Closed).Select(d => d.Caption).Contains(newValue))
{
DocumentList.Where(d => d.Closed).First(d => d.Caption.Equals(newValue)).Closed = false;
}
}
public class DocumentPanelInfo : DocumentPanel, IMVVMDockingProperties
{
public string TargetName
{
get
{
return "dg";
}
set
{
throw new System.NotImplementedException();
}
}
}
|