2016-08-28 2 views
0

나는 그것의 ItemsSource가 posteViewSource로부터 공급 받고 그것의 SelectedItem이 superviseurViewSource에 연결된 테이블의 idPoste 필드에 바인딩되도록 콤보 박스를 갖고 싶습니다. {정적 리소스 superviseurViewSource} :서로 다른 출처의 두 속성에 바인딩하는 방법은 무엇입니까?

 <ComboBox x:Name="idPosteComboBox" DataContext="{StaticResource posteViewSource}" ItemsSource="{Binding}" Height="23" Width="120" DisplayMemberPath="idPoste" /> 

콤보는 누구의 DataContext로 설정되어 그리드에 있습니다

<Window.Resources> 
    <local:StagesBDDataSet x:Key="stagesBDDataSet"/> 
    <CollectionViewSource x:Key="superviseurViewSource" Source="{Binding Superviseur, Source={StaticResource stagesBDDataSet}}"/> 
    <CollectionViewSource x:Key="posteViewSource" Source="{Binding Poste, Source={StaticResource stagesBDDataSet}}"/> 
</Window.Resources> 

여기 내 콤보 정의입니다. 항목과의 바인딩은 완벽하게 작동하지만 SelectedItem 속성에 대해 다른 DataContext를 가질 수 있는지 여부는 알 수 없습니다. 어떤 힌트도 고맙게 생각합니다. 감사합니다.

+0

하지 항목의이'idPoste'에'SelectedItem' 바인딩, 의미가 있습니까 'CollectionViewSource' -> no,이 컬렉션의 어떤 아이템에 바인딩 될까요? – Aybe

+0

그것은 idPoste 일 수도 있습니다. 콤보 박스는 Poste 테이블 (위에서 언급 한 collectionviewsource에 링크 됨)의 행으로 채워져 잘 작동합니다. 이제 내가 원하는 것은 콤보 박스의 선택된 항목을 Superviseur 테이블의 collectionviewsource의 현재 행에있는 idPoste 필드와 바인딩하는 것입니다. 그것을 설명하는 것이 다소 도전적이며, 이것이 도움이되기를 바랍니다. – snoreau

+0

그럼이 표에서 현재 선택된 항목을 추적해야합니다. 아마도 데이터 표나 다른 것을 사용할 것입니다 : http://stackoverflow.com/a/13755582/361899. 'ComboBox DataContext = "{StaticResource resource1}"Content = "{Binding TextInResource1}"툴팁 = "{Binding ElementName = resource2, Path = Something}"과 같은 컨트롤에서 다른 곳의 속성에 바인딩 할 수 있다면/> ' – Aybe

답변

0

당신은 ItemSource 바인딩 및 다른 selectedItem가 바인딩을 가질 수 있습니다, 그래서 당신은 쓸 수 있습니다 : -> 예,에 바인딩

<ComboBox x:Name="idPosteComboBox" 
    DataContext="{StaticResource posteViewSource}" ItemsSource="{Binding}" 
    SelectedItem="{Binding ---another binding---}" 
    IsSynchronizedWithCurrentItem="True" 
    Height="23" Width="120" DisplayMemberPath="idPoste" /> 
+0

시간 내 주셔서 감사합니다. 나는 그것을 시도했다. 그러나 어떤 운도. 이 SelectedItem의 바인딩 괜찮습니까? SelectedItem = "{바인딩 소스 = superviseurViewSource, Path = idPoste, Mode = TwoWay}" – snoreau

관련 문제