6

クライアントがテキストを入力してリストから選択できるようにしたいので、SelectedTextSelectedItemプロパティをオートコンプリートボックスにバインドします。正常に動作していますが...オートコンプリートボックスSelectedTextバグ

メインページにはDataGridが1つあります。グリッド(SelectedItem)からレコードを選択すると、そのレコードをポップアップウィンドウのAutocompleteBoxに設定します。時にはそれは動作しますが、しばしば動作しません。

この問題はどうすればよいですか?

この

は私のXAMLです:

<Sdk:AutoCompleteBox Grid.Column="3" Grid.Row="3" Height="18" Width="150" 
    IsTextCompletionEnabled="True" TabIndex="9" HorizontalAlignment="Left" 

    Text="{Binding ElementName=ResEdit,Path=DataContext.SelectedDemoText,Mode=TwoWay}" 
    ItemsSource="{Binding ElementName=ResEdit,Path=DataContext.DemoList,Mode=OneWay}" 
    ItemTemplate="{StaticResource DemoTemplate}" 
    ValueMemberPath="DemoCode" 
    LostFocus="AutoCompleteBox_LostFocus" 
    Margin="0,0,21,0" Padding="0"> 
    </Sdk:AutoCompleteBox> 

このプロパティは、私の見解モデルであるとのDataGridにバインド:

public InvoicesDTO SelectedInvoice 
{ 
    get { return _selectedInvoice; } 
    set 
    { 
     SelectedInvoice = value; 
     SelectedDomoText = SelectedInvoice.DemoText.Trim(); 
     RaisePropertyChanged("SelectedInvoice"); 
    } 
} 
+0

あなたの質問は何ですか? – ean5533

+0

私は問題を持っていますSelectedTextプロパティを設定してくださいいくつかの時間は適切に設定しなければなりませんし、適切な時間を設定しないでください –

+2

あなたのコードサンプルや画像の一部を投稿できますか? – Amitd

答えて

3

あなたが使用してはならない機能の両方SelectedTextのSelectedItemオートコンプリートオートコンプリートボックスのバグです..... テキストボックスの可視性をのオートコンプリートボックスをGotFocusとLossFocusに設定することをお勧めします。あなたが挑戦的にあなたを解決するこの方法あなたの問題

private void DemoAutoComplete_LostFocus(object sender, RoutedEventArgs e) 
      { 
       DemoTextBox.Visibility = Visibility.Visible; 
       DemoAutoComplete.Visibility = Visibility.Collapsed; 
       DemoTextBox.Text = OCRAutoComplete.Text; 

       ((DemoVM)this.DataContext).SelectedDemoText = DemoAutoComplete.Text; 
      } 



private void DemoTextBox_GotFocus(object sender, RoutedEventArgs e) 
    { 
     DemoAutoComplete.Text = OctTextBox.Text; 
     DemoTextBox.Visibility = Visibility.Collapsed; 
     DemoAutoComplete.Visibility = Visibility.Visible; 
     DemoAutoComplete.Focus(); 
    } 
+0

あなたのansは私の質問とcompitibleではありません –

関連する問題