2009-05-23 5 views

답변

0

불행하게도이 일을 문서화 방법이있을 것 같지 않습니다. 내가 아는 유일한 방법은 아래와 같이 리플렉션을 사용하는 것입니다.하지만이 기술은 RichTextBox의 내부 동작에 액세스합니다. 현재 버전의 WPF에서 작동하지만 앞으로도 계속 작동 할 것이라는 보장이 없으므로 책임지고 사용하십시오.

PropertyInfo textEditorPropertyInfo = typeof(RichTextBox).GetProperty("TextEditor", BindingFlags.NonPublic | BindingFlags.Instance); 

     if (textEditorPropertyInfo == null) 
      throw new NotSupportedException("SetOverwriteable not support on this platform"); 

     object textEditor = textEditorPropertyInfo.GetValue(this, null); 
     PropertyInfo overtypeModePropertyInfo = textEditor.GetType().GetProperty("_OvertypeMode", BindingFlags.NonPublic | BindingFlags.Instance); 

     if (overtypeModePropertyInfo == null) 
      throw new NotSupportedException("SetOverwriteable not support on this platform"); 

     overtypeModePropertyInfo.SetValue(textEditor, true, null); 

위의 요구 생성자 후에 발생합니다.

관련 문제