2014-07-15 2 views
0

주 메뉴의 콤보 상자에서 선택된 여러 데이터베이스에서 검색 할 사이드 패널을 만들었습니다.바인드 된 데이터 그리드가 데이터 집합 변경시 업데이트되지 않음

: 나는 무효 방법을 콤보 상자가 업데이트 될 때마다 넣어

public partial class SideRecordSearch : UserControl 
{ 
    public DataTable dataSet 
    { 
     get; 
     set; 
    } 

    public SideRecordSearch(MainWindow Window) 
    { 
     this.dataSet = getData(Window.System_Selected);    
     InitializeComponent(); 
    } 

    internal void Change_System_Subsystem(string System_Selected) 
    { 

     this.dataSet = getData(System_Selected); 

     Search_Record.Items.Refresh(); 
    } 

} 

그리고 MainWindow를 클래스 :

<UserControl x:Class="Sum.SideRecordSearch" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" 
      xmlns:s="clr-namespace:System;assembly=mscorlib"    
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      Name="Search_Mode"> 
    <UserControl.Resources> 
     <ResourceDictionary> 

      <xcdg:DataGridCollectionViewSource x:Key="Record_Search_DGCVS" 
              Source="{Binding ElementName=Search_Mode, Path=dataSet}" 
              AutoCreateItemProperties="True" 
              AutoCreateForeignKeyDescriptions="True" 
              DefaultCalculateDistinctValues="False"/> 
     </ResourceDictionary> 
    </UserControl.Resources> 
<Grid> 
     <xcdg:DataGridControl x:Name="Search_Record" 
           ItemsSource="{Binding Source={StaticResource Record_Search_DGCVS} }" 
           ReadOnly="True"/> 
</Grid> 

나는 데이터를 나는 다음과 같은 코드를 사용하여 응용 프로그램을 처음 실행할 때 채워

public partial class MainWindow : RibbonWindow 
    { 

     internal string System_Selected; 
     SideRecordSearch Search_Panel; 

     public MainWindow() 
     { 
      InitializeComponent(); 

      System_Selected = ((ComboBoxItem)IP_System.SelectedItem).Name; 
      Search_Panel = new SideRecordSearch(this); 

      this.QuickPanel.Children.Add(Search_Panel); 

     } 

     private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) 
     { 
      try 
      { 
       System_Selected = ((ComboBoxItem)System.SelectedItem).Name; 

       Search_Panel.Change_System_Subsystem(System_Selected); 
      } 
      catch 
      { 

      } 
     } 

} 

그러나 내가 콤보 상자를 변경하면 데이터 세트가 업데이트되지만 DataGrid는 처음으로 데이터 세트가 채워진 시점의 원래 항목을 계속 표시합니다.

답변

0

가지고 UpdateSourceTrigger =

<xcdg:DataGridCollectionViewSource x:Key="Record_Search_DGCVS" 
              Source="{Binding ElementName=Search_Mode, Path=dataSet,UpdateSourceTrigger="PropertyChanged"}" 
              AutoCreateItemProperties="True" 
              AutoCreateForeignKeyDescriptions="True" 
              DefaultCalculateDistinctValues="False"/> 

'을하여 PropertyChanged'와 DynamicResource하기 위해 정적 리소스를 변경

<xcdg:DataGridControl x:Name="Search_Record" 
             ItemsSource="{Binding Source={DynamicResource Record_Search_DGCVS} }" 
             ReadOnly="True"/> 
관련 문제