2012-02-07 2 views
0

내 MainWindow의 가운데에 내 모달 대화 상자를 호스팅하는 대신 내 MainWindow 내의 ContentControl 중 하나에서 호스트를 호스팅하고 싶습니다. 누군가가 나에게이 문제에 대해 어떻게 조언 할 수 있기를 바랍니다. 감사.ContentControl에서 모달 대화 상자 호스팅

+2

"모달 대화"란 무엇입니까? 예를 든다. – Seekeer

답변

0

이 동작을 수행하기 위해 사용자 정의 UserControl이 있습니다. 코드와 기사는 here를 발견하고,이처럼 사용할 수 있습니다 :

<local:PopupPanel 
    Content="{Binding PopupContent}" 
    local:PopupPanel.PopupParent="{Binding ElementName=PopupParentPanel}" 
    local:PopupPanel.IsPopupVisible="{Binding IsPopupVisible}" /> 
+0

고마워, Rachel ... :) – bbdaffy

1

난 당신이 주요 내용에 모달 내용을 표시 할 수 있습니다 사용자 정의 FrameworkElementgithub에 대한 예제가있다.

제어

는 다음과 같이 사용할 수 있습니다

<c:ModalContentPresenter IsModal="{Binding DialogIsVisible}"> 
    <TabControl Margin="5"> 
      <Button Margin="55" 
        Padding="10" 
        Command="{Binding ShowModalContentCommand}"> 
       This is the primary Content 
      </Button> 
     </TabItem> 
    </TabControl> 

    <c:ModalContentPresenter.ModalContent> 
     <Button Margin="75" 
       Padding="50" 
       Command="{Binding HideModalContentCommand}"> 
      This is the modal content 
     </Button> 
    </c:ModalContentPresenter.ModalContent> 

</c:ModalContentPresenter> 

특징 :

  • 표시 임의의 내용을.
  • 모달 콘텐츠가 표시되는 동안 기본 콘텐츠를 사용하지 않도록 설정하지 않습니다.
  • 모달 내용이 표시되는 동안 기본 내용에 대한 마우스 및 키보드 액세스를 비활성화합니다.
  • 전체 응용 프로그램이 아닌 해당 응용 프로그램에만 적용됩니다.
  • IsModal 속성에 바인딩하여 MVVM 친화적 인 방법으로 사용할 수 있습니다.