2012-04-26 15 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> 

この画面では、このような新しいウィンドウを呼び出すボタンを、持っています:

 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(); 

ウィンドウをサブクラス化し、そのプロバイダプロパティを追加する必要があります。代わりに、XDocumentプロパティを作成し、子ウィンドウのすべてをバインドすることもできます。

関連する問題