2012-02-24 3 views
2

편집 가능한 wpf 콤보 박스가 있습니다. 마지막 문자로 스크롤하지 않고 길이보다 긴 문자를 입력하면 텍스트가 컨트롤에서 벗어나 보이지 않습니다. 이 문제를 해결할 수있는 방법이 있습니까?편집 가능한 콤보 박스 텍스트 스크롤

<ComboBox Margin="11,0,0,0" 
      Height="23"         
      Width="200" 
      IsEditable="True" 
      Text="{Binding Profile.Mat}" 
      ItemsSource="{Binding Statuses}" /> 

textscrolling

+0

이 문제가 해결 되었습니까? 그것은 나를 위해 작동하지 않습니다. – Ben

답변

0

당신은 콤보 상자의 템플릿 내부 TextBox의 인 selectionchanged 이벤트를 처리하여이 작업을 수행 할 수 있습니다. 코드 뒤에 다음 코드를 추가하십시오.

 public override void OnApplyTemplate() 
     { 
      base.OnApplyTemplate(); 
      if (comboBox.ApplyTemplate()) 
      { 
       TextBox editableTextBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox); 
       editableTextBox.SelectionChanged += new RoutedEventHandler(editableTextBox_SelectionChanged); 
      } 
     } 

     void editableTextBox_SelectionChanged(object sender, RoutedEventArgs e) 
     { 
      TextBox textBox = sender as TextBox; 
      if (textBox != null) 
      { 
       textBox.ScrollToHome(); 
       e.Handled = true; 
      } 
     } 
+0

필요한 경우 알려주세요. – gaurawerma

관련 문제