2009-06-26 2 views
0

아래 그림은 왼쪽에 목록 상자가 있고 오른쪽에 콘텐츠 컨트롤이있는 WPF 양식을 나타내는 훌륭한 작품입니다. 목록 상자가 비어 있으면 내용 컨트롤이 보이지 않도록 설정하려고합니다. 어떤 속성/이벤트에 연결해야합니까?ContentControl 숨기기

----- ----- 
| a | | c | 
| b | | | 
----- ----- 
당신이 (가) ContentControl을위한 스타일을 만들고 목록 0 항목이있는 경우과 같이, 결정하기 위해 트리거를 사용한다

답변

3

: 완벽하게 작동

<ListBox x:Name="uiList">...</ListBox> 
<ContentControl> 
     <ContentControl.Content> 
      <TextBox Text="List has items." /> 
     </ContentControl.Content> 
     <ContentControl.Style> 
      <Style TargetType="{x:Type ContentControl}"> 
       <Style.Triggers> 
        <DataTrigger Binding="{Binding ElementName=uiList, Path=Items.Count}" 
           Value="0"> 
         <Setter Property="Visibility" 
           Value="Collapsed" /> 
        </DataTrigger> 
       </Style.Triggers> 
      </Style> 
     </ContentControl.Style> 
    </ContentControl> 
+0

, 감사합니다! –