c# - How to customize a PlaceholderText in a Listbox to have a specific color in UWP -
i working on listbox have using placeholdertext property of textbox. here code listbox. using popup implement content
<popup x:name="reasoncodepopup" x:fieldmodifier="public" isopen="{binding showfuelchangereasonpopup, mode=twoway}" height="420" width="1100" grid.row="0" grid.rowspan="2" islightdismissenabled="true"> <grid height="397" width="1100" > <textblock visibility="collapsed" name="txtfuelreason" text="{x:bind viewmodel.fuelplaninfo.extrafuelreason,mode=twoway}"/> <listbox margin="20" name="lstfuelreason" selectionchanged="lstfuelreason_selectionchanged" background="#414042" height="420" width="1100" > <listbox.itemcontainerstyle> <style targettype="listboxitem"> <setter property="background" value="transparent"/> <setter property="margin" value="0"/> <setter property="padding" value="0"/> <setter property="height" value="40"/> <setter property="padding" value="0"/> </style> </listbox.itemcontainerstyle> <listboxitem isenabled="false" margin="43.5,30.5,748.5,0"> <textblock text="reason code" fontsize="32" fontfamily="helvetica" fontweight="bold" foreground="#ffffff" ishittestvisible="false" /> </listboxitem> <listboxitem isenabled="false"> <border margin="43,0,57,0" borderbrush="#979797" borderthickness="0,0,0,1" width="948"/> </listboxitem> <listboxitem> <textblock text="atc" margin="43,0,57,0" foreground="#ffffff" fontsize="32" fontfamily="{themeresource bold}" fontweight="normal" selectionhighlightcolor="blue"></textblock> </listboxitem> <listboxitem isenabled="false"> <border margin="43,0,57,0" borderbrush="#979797" borderthickness="0,0,0,1" width="948"/> </listboxitem> <listboxitem> <textblock text="weather" margin="43,0,57,0" foreground="#ffffff" fontsize="32" fontfamily="{themeresource bold}" fontweight="normal"></textblock> </listboxitem> <listboxitem isenabled="false" margin="0"> <border margin="43,0,57,0" borderbrush="#979797" borderthickness="0,0,0,1" width="948"/> </listboxitem> <listboxitem height="50"> <textbox placeholdertext="other" margin="43.5,0,0,0" tapped="fuelreasonother_tapped" textchanged="textbox_textchanged" foreground="#ff0078d7" fontsize="32" fontfamily="{themeresource bold}" fontweight="normal" style="{staticresource transparenttextbox}"/> </listboxitem> </listbox> </grid> </popup> i want <textbox placeholdertext="other"/>modify foreground color of "other" text typed here appear in blue. know need play contenttemplate not able so. can help?
if override textcontrol defined brushes, can change colors want without having theme whole textbox control. tested following code, , worked:
<textbox placeholdertext="other" margin="43.5,0,0,0" fontsize="32" fontweight="normal"> <textbox.resources> <solidcolorbrush x:key="textcontrolplaceholderforeground" color="lightblue"/> <solidcolorbrush x:key="textcontrolplaceholderforegroundfocused" color="lightblue" /> <solidcolorbrush x:key="textcontrolplaceholderforegroundpointerover" color="lightblue" /> <solidcolorbrush x:key="textcontrolforeground" color="blue" /> <solidcolorbrush x:key="textcontrolforegroundfocused" color="blue" /> <solidcolorbrush x:key="textcontrolforegroundpointerover" color="blue" /> </textbox.resources> </textbox> note: removed bindings , event handlers keep ui elements. should able add textbox.resources textbox , see work.
the textbox.resources override default brushes textcontrol (which within textbox). these brush names used control draw in specific situations.
let me know if trick.
Comments
Post a Comment