visual studio - Change colour and size of a certain string in a textblock (Windows Phone 7) in VB.net -
hi have button (btnadd) adds content of textbox (txtname) textblock (lblname). want add date textblock when btnadd pressed want different font size , colour. far code looks like
lblname.text = txtname.text " " + datetime.now
i want datetime.now different size , colour. possible?
edit: instead of label need display in listbox new code need on is:
listbox1.items.add(txtname.text " " + datetime.now)
what want assign inlines
rather text
:
lblname.inlines.clear(); lblname.inlines.addrange(new inline[] { new run(txtname.text + " ") { foreground = new solidcolorbrush(color.black) }, new run(datetime.now.tostring()) { foreground = new solidcolorbrush(color.green) } });
you can (and should) bind run's directly xaml:
<textblock> <textblock.inlines> <run text="{binding name}" foreground="black" /> <run text=" " foreground="black" /> <run text="{binding now}" foreground="green" /> </textblock.inlines> </textblock>
Comments
Post a Comment