c# - TextBox with an Error bob -
i want have textbox displays error bob next it. wrote below code:
<textbox text="my textbox" horizontalalignment="center" verticalalignment="center" height="75" width="75"> <textbox.template> <controltemplate> <dockpanel> <image..."error bob image added here"/> <border borderbrush="red" borderthickness="1.2"/> </dockpanel> </controltemplate> </textbox.template> </textbox>
i able see same in designer. when run solution, see textbox red border. image (i.e., error bob) not visible. can suggest why happens?
try set property lastchildfill="true"
of dockpanel
:
<textbox text="my textbox" horizontalalignment="center" verticalalignment="center" height="75" width="75"> <textbox.template> <controltemplate> <dockpanel lastchildfill="true"> <textbox borderthickness="0"/> <textblock text="error bob image added here" width="100"/> <!--<image..."error bob image added here"/>--> <border borderbrush="red" borderthickness="1.2"/> </dockpanel> </controltemplate> </textbox.template> </textbox>
you can use textblock
width
instead of image
show text "error bob".
update: double checked , works. please, see following image:
in addition, can use stackpanel
, if okay:
<textbox text="my textbox" horizontalalignment="center" verticalalignment="center" height="75" width="275"> <textbox.template> <controltemplate> <stackpanel orientation="horizontal"> <textbox borderthickness="0"/> <textblock text="error bob image added here" width="100"/> <border borderbrush="red" borderthickness="1.2"/> </stackpanel> </controltemplate> </textbox.template> </textbox>
Comments
Post a Comment