c# - How do I select text in RichTextBox while keeping keyboard focus in another TextBox -


i'm working on chat window in wpf hosts forms.richtextbox.

<windowsformshost x:name="wfh">    <wf:richtextbox x:name="txtmain" hideselection="false" readonly="true" multiline="true"/> </windowsformshost> 

below richtextbox regular wpf textbox.

<textbox x:name="txtsend" textwrapping="wrap" acceptsreturn="true"/> 

i'd keyboard focus stay on textbox, yet still allow user select text in wfh's richtextbox , scroll.

i've tried changing keyboard focus on mouseup in txtmain, cannot scroll, , it's not possible copy using ctrl+c.

any ideas?

you might want take @ sample. if want multiple focus have use focusscope.

sample code link

static void ongotkeyboardfocus(object sender, keyboardfocuschangedeventargs e) {     iinputelement focusedelement = e.newfocus;     (dependencyobject d = focusedelement dependencyobject;          d != null; d = visualtreehelper.getparent(d)) {         if (focusmanager.getisfocusscope(d)) {             d.setvalue(focusmanager.focusedelementproperty, focusedelement);             if (!(bool)d.getvalue(isenhancedfocusscopeproperty)) {                 break;             }         }     } } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -