2013-10-25 1 views
0

셀 편집 템플릿의 DataGrid 안에 텍스트 상자가 있습니다. 텍스트 상자에 입력 된 텍스트 을 각 셀의 텍스트 블록에 바인딩하고 싶습니다. 이 코드를 시도했지만 작동하지 않습니다.DataGrid 내에서 texbox에 입력 된 텍스트를 검색하는 방법

여기 내 XAML입니다 :

    <DataTemplate> 
         <StackPanel Orientation="Horizontal"> 
          <!--<ComboBox x:Name="monday" Width="50" IsSynchronizedWithCurrentItem="true" Loaded="monday_Loaded" SelectionChanged="monday_SelectionChanged"></ComboBox>--> 
          <ComboBox x:Name="monday" Width="30" ItemsSource="{Binding Path=Subjects}" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" SelectedItem="{Binding SelectedCollectionItem,Mode=TwoWay}"  Loaded="monday_Loaded" SelectionChanged="monday_SelectionChanged"></ComboBox> 
          <ComboBox x:Name="staff" Width="30" ItemsSource="{Binding Path=mondstaff}" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" SelectedItem="{Binding SelectedCollectionItem1,Mode=TwoWay}" Loaded="staff_Loaded" SelectionChanged="staff_SelectionChanged"></ComboBox> 
          <TextBox x:Name="monothers" Visibility="Hidden" Text="{Binding Path=Subjects}" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" SelectedText ="{Binding SelectedCollectionItem2,Mode=TwoWay}" Width="30" TextChanged="monothers_TextChanged"></TextBox> 
          <!--<ComboBox x:Name="staff" Width="50" Loaded="staff_Loaded"></ComboBox>--> 
         </StackPanel> 
        </DataTemplate> 

여기 내 코드입니다 :

public string SelectedCollectionItem 
     { 
      get { return _SelectedCollectionItem; } 
      set 
      { 
       _SelectedCollectionItem = value; 
       RaiseProperty2("SelectedCollectionItem2"); 
      } 
     } 

사람이 그것을 수행하는 방법을 알고있는 경우

은, 친절하게 도와주세요.

답변

0

난 당신이

public void monothers_TextChanged(object sender, TextChangedEventArgs e) 
{ 
    var binding = ((TextBox)sender).).GetBindingExpression(TextBox.TextProperty); 
    binding.UpdateSource(); 
} 

자세한 내용

이 토론을 참조

당신의 코드 숨김에서이 ​​코드를 놓쳤다 생각

How to hookup TextBox's TextChanged event and Command in order to use MVVM pattern in Silverlight

또한이 블로그를 참조 할 필요가

Make a Silverlight TextBox update its binding on every character with a Behavior

+0

의견을 보내 주셔서 감사합니다. – prabhakar

관련 문제