c# - Managing keyboard focus with custom TextBox control template -


currently i'm working on wpf project has defined custom style textbox. among other things, override default control template textbox. control template looks (i've removed lot of templatebinding stuff since it's not relevant).

<border>     <grid>         <grid.columndefinitions>             <columndefinition width="*"/>             <columndefinition width="auto"/>         </grid.columndefinitions>         <scrollviewer x:name="part_contenthost"                       istabstop="false"                       background="{x:null}"                       verticalalignment="center"                       borderthickness="0"/>          <contentpresenter grid.column="1" margin="5,0,0,0" focusable="false"                           content="{templatebinding local:unitconversion.info}"                           contenttemplateselector="{dynamicresource selectorkey}"/>     </grid> </border> 

essentially adds contentpresenter display combo box allowing user select different units used display or entry text box. template selector selects between user control (which combobox) or empty template if text box doesn't have associated unit data (the content null).

the problem

since combo box part of text box control template, interacting combo box gives keyboard focus text box without placing caret visual text box. elsewhere have keyboard control made visible when text box gets keyboard focus (the keyboard listening custom routed events, these raised when textbox gets focus.

the question

is there way can prevent text box getting focus when other actual text entry technically got focus? desired behavior manipulating combo box doesn't result in on-screen keyboard popping up.

my gut instinct here tells me can't want since focus logic happens @ textbox level , doesn't care contents of control template. i'm curious if might able think of kind of workaround.

i'd avoid introducing custom text box control handle since don't idea of application-specific custom controls (especially considering how far we've gotten current one).


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -