c# - WPF How do i set text as textbox's background in code behind? -


is possible set text textbox's background in code behind?

 textbox.background = ?? 

or have use textblock , assign text textbock add textblock textbox's background? how do that?

you can use visualbrush draw elements on background of element

example:

<textbox>     <textbox.background>         <visualbrush stretch="none" alignmentx="left">              <visualbrush.visual>                 <textbox text="stackoverflow"/>             </visualbrush.visual>         </visualbrush>     </textbox.background> </textbox> 

or in code behind

textbox.background = new visualbrush(new textbox { text = "stackoverflow" }) {     alignmentx = alignmentx.left,     stretch = stretch.none }; 

result:

enter image description here


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -