2016-09-21 10 views
0

그래, 비교적 관련있는 문제가 있습니다. WPF에서 창을 만들려고합니다. 이 윈도우의 주 요소는 DataGrid입니다. DataGrid의 각 행에는 DataGrid.RowDetailsTemplate을 사용하여 설정 한 DetailsPane이 있습니다. 특정 행 별 값에 따라 다른 요소를 표시하려면 DetailsPane이 필요합니다. 이를 위해 DataTemplate의 루트에 ContentControl을 배치하고 DataTriggers의 Style을 사용하여 Content 속성을 설정했습니다. 자, 안에이 Setters 중 하나는 ComboBox입니다. 이 ComboBox는 해당 ItemsSource가 Window 수준의 종속성 속성에 저장된 목록에 바인딩되어야합니다 (행과 관계없이 같은 목록이기 때문에). 아래는 내가 찾고 있어요 무엇의 단순화 된 버전은 다음과 같습니다DataTemplate WPF의 스타일 설정 기에서 바인딩

<Window> 
    ... 
    <DataGrid> 
     ... 
     <DataGrid.RowDetailsTemplate> 
      <DataTemplate> 
       <ContentControl> 
        <Style TargetType="ContentControl"> 
         <Style.Triggers> 
          <DataTrigger Binding="{Binding RowSpecificBooleanProperty}" Value="False"> 
           <Setter Property="Content"> 
            <Setter.Value> 
             ... 
             <ComboBox ItemsSource={HowDoIBindThisToTheWindowProperty}/> 
            </Setter.Value> 
           </Setter> 
          </DataTrigger> 
         </Style.Triggers> 
        </Style> 
       </ContentControl> 
      </DataTemplate> 
     </DataGrid.RowDetailsTemplate> 
    </DataGrid> 
</Window> 

그래서 알아 내기 위해 노력하고있어 최상위 윈도우의 종속성 속성에 해당 콤보 상자의 ItemsSource를 바인딩하는 방법이다. 앤디 아이디어를 어떻게 달성 할 수 있을까요?

편집 :

내가 전에 언급해야하지만 난 이미 바인딩에 {RelativeSource AncestorType = 윈도우}와 ElementName을 사용하여 시도했습니다. 두 경우 모두 ComboBox의 목록은 런타임에 비어 있습니다.

+0

RelativeSource가 (= 윈도) (http://stackoverflow.com/questions/84278/how-do-i-use-wpf-bindings-with-relativesource) 또는 바인딩 ElementName을 일반적으로 사용되는 – ASh

답변

0
ItemsSource="{Binding WhateverList, RelativeSource={RelativeSource AncestorType=Window}}" 
+0

죄송 합니다만 나는 이미 이것을 시도했다. 나는 그것을 질문에 넣었어야했는데 그것을 업데이트했다. –