2012-04-26 3 views
3

나는 다음과 같은 설정을 가지고 :필터링이 결합되어 콤보 상자에서 값을 선택 제거합니다

이 메인 화면입니다 :

<ListView Name="lineData" Grid.Row="2" ItemsSource="{Binding ElementName=This, Path=LineInformation, ValidatesOnDataErrors=True}" 
       ItemContainerStyle="{StaticResource ItemStyle}" PreviewMouseUp="lineData_PreviewMouseUp" SelectedIndex="0" 
       Foreground="{StaticResource {x:Static SystemColors.ControlTextBrushKey}}"> 
     <ListView.View> 
      <GridView x:Name="gridViewItems" AllowsColumnReorder="false"> 
       <GridViewColumn Header="Product" Width="Auto"> 
        <GridViewColumn.CellTemplate> 
         <DataTemplate> 
          <StackPanel Orientation="Horizontal"> 
           <ComboBox Name="descriptionComboBox" Loaded="description_Loaded" 
            DisplayMemberPath="Description" SelectedItem="{Binding Path=Product}" SourceUpdated="descriptionComboBox_SourceUpdated" 
            MinWidth="200" Width="Auto" SelectionChanged="description_SelectionChanged" TargetUpdated="descriptionComboBox_TargetUpdated"> 
            <ComboBox.ItemsSource> 
            <Binding Source="{StaticResource XmlFile}" /> 
            </ComboBox.ItemsSource> 
           </ComboBox> 
          </StackPanel> 
         </DataTemplate>        
        </GridViewColumn.CellTemplate> 
       </GridViewColumn> 
      </GridView> 
     </ListView.View> 
    </ListView> 

이 화면이 같은 새 창을 호출하는 버튼, :

,536 :

 Window newWindow = new Window(); 
     buildWindow.Owner = this; //MainWindow is the owner 
     buildWindow.ShowDialog(); 

이 새로운 창은 다음과 같이 첫 번째 창에서 콤보 상자에있는 값을 필터링

 XmlDataProvider provider = Owner.FindResource("XmlFile") as XmlDataProvider; 
     provider.XPath = _configuration.CreateFilterQuery(); 
     provider.Refresh(); 

그래서이 콤보 박스에는이 XmlFile에 대한 바인딩이 있습니다. 내가 가지고있는 문제는 이제 콤보 박스가 새로운 필터의 범주에 속하면 그 값을 콤보 박스에 표시해야한다는 것입니다.

하지만 .Refresh() 함수를 호출하면 콤보 상자의 선택된 색인이 재설정됩니다.

XPath 쿼리를 적용한 후 표시된 텍스트를 유지하는 방법에 대한 아이디어가 있으십니까?

감사합니다.

답변

0

새로 고침 전에 선택 사항을 기억하고 새 필터 다음에 값이 존재하는지 확인한 다음 선택해야합니까?

0

자녀의 윈도우에 자신의 XmlDataProvider가 있어야한다고 생각합니다. 어쩌면 이렇게 할 수 있을까요?

 XmlDataProvider provider = Owner.FindResource("XmlFile") as XmlDataProvider; 
     XDocument cloneDoc = new XDocument(provider.Document); 

     XmlDataProvider childProvider = new XmlDataProvider(); 
     childProvider.Document = cloneDoc; 
     childProvider.XPath = _configuration.CreateFilterQuery(); 
     childProvider.Refresh(); 

     Window newWindow = new Window(); 
     newWindow.Provider = childProvider; 
     newWindow.Owner = this; //MainWindow is the owner 
     newWindow.ShowDialog(); 

하위 클래스를 만들고 해당 Provider 속성을 추가해야합니다. XDocument 속성을 만들고 자식 창에 모든 것을 바인딩 할 수도 있습니다.

관련 문제