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:
Comments
Post a Comment