2011-10-31 2 views
7

프로젝트에서 AvalonDock을 사용하여 도구 창을 이용하고 있습니다.AvalonDock 컨텍스트 메뉴를 사용자 정의 할 수 있습니까?

도구 모음 제목 표시 줄을 마우스 오른쪽 단추로 클릭 할 때 탭이있는 문서가 필요하지 않으며 "탭 모양의 문서로 연결"상황에 맞는 메뉴 항목을 사용하지 않으려합니다. 이것이 가능한가?

감사합니다.

답변

3

이것은 단순한 속성 설정이라고 생각합니다.

<ad:SampleDockableContent DockableStyle="DockableToBorders" 
        x:Name="DockingManagerPropertiesHost" 
        Title="Only dock to borders"> 
</ad:SampleDockableContent> 

과 CONTECT 메뉴 않으려면이 방법을 대체 할 수 있습니다 :

public partial class SampleDockableContent : DockableContent 
{ 
    public SampleDockableContent() { 
    this.InitializeComponent(); 
    this.DataContext = this; 
    } 

    protected override bool CanExecuteCommand(ICommand command) { 
    if (command == DockableContentCommands.ShowAsDocument) { 
     if (this.DockableStyle == DockableStyle.DockableToBorders) { 
     return false; 
     } 
     if (this.State == DockableContentState.Document) { 
     return false; 
     } 
    } 
    return base.CanExecuteCommand(command); 
    } 
} 
을 내가 당신이 원하는 스타일에 DockableStyle 속성을 변경할 수 있습니다 CodePlex의 76560.

에서 최신 소스를 사용

여기에 플래그가 있습니다 :

/// <summary> 
/// Defines how a dockable content can be dragged over a docking manager 
/// </summary> 
/// <remarks>This style can be composed with the 'or' operator.</remarks> 
public enum DockableStyle : uint 
{ 
    /// <summary> 
    /// Content is not dockable at all 
    /// </summary> 
    None = 0x0000, 

    /// <summary> 
    /// Dockable as document 
    /// </summary> 
    Document = 0x0001, 

    /// <summary> 
    /// Dockable to the left border of <see cref="DockingManager"/> 
    /// </summary> 
    LeftBorder = 0x0002, 

    /// <summary> 
    /// Dockable to the right border of <see cref="DockingManager"/> 
    /// </summary> 
    RightBorder = 0x0004, 

    /// <summary> 
    /// Dockable to the top border of <see cref="DockingManager"/> 
    /// </summary> 
    TopBorder = 0x0008, 

    /// <summary> 
    /// Dockable to the bottom border of <see cref="DockingManager"/> 
    /// </summary> 
    BottomBorder= 0x0010, 

    /// <summary> 
    /// A <see cref="DockableContent"/> with this style can be hosted in a <see cref="FloatingWindow"/> 
    /// </summary> 
    Floating = 0x0020, 

    /// <summary> 
    /// A <see cref="DockableContent"/> with this style can be the only one content in a <see cref="DockablePane"/> pane (NOT YET SUPPORTED) 
    /// </summary> 
    /// <remarks>This style is not compatible with <see cref="DockableStyle.Document"/> style</remarks> 
    Single = 0x0040, 

    /// <summary> 
    /// A <see cref="DockableContet"/> with this style can be autohidden. 
    /// </summary> 
    AutoHide = 0x0080, 

    /// <summary> 
    /// Dockable only to a border of a <see cref="DockingManager"/> 
    /// </summary> 
    DockableToBorders = LeftBorder | RightBorder | TopBorder | BottomBorder | AutoHide, 

    /// <summary> 
    /// Dockable to a border of a <see cref="DockingManager"/> and into a <see cref="DocumentPane"/> 
    /// </summary> 
    Dockable = DockableToBorders | Document | Floating, 

    /// <summary> 
    /// Dockable to a border of a <see cref="DockingManager"/> and into a <see cref="DocumentPane"/> but not in autohidden mode (WinForms controls) 
    /// </summary> 
    DockableButNotAutoHidden = Dockable & ~AutoHide 
} 
+0

대단히 고맙습니다. "탭 문서로 도킹"하나. 컨텍스트 메뉴에서 항목을 제거하고 이름을 변경할 수 있는지 알고 계십니까? 부동 모드에서 몇 가지 오류가 발견되었지만 DockableContent의 ContextMenu 속성이 항상 null 인 것으로 나타났습니다. –