i using imagebrush atextblock foreground. works fine when textblock underline, line not show.
to reproduce. in xaml
<textblock x:name="textblock" fontsize="80" fontweight="bold"> <underline>this text</underline> </textblock> in code behind
uri uri = new uri("ms-appx:///assets/0.png"); bitmapimage bmp = new bitmapimage(uri); imagebrush imagebrush = new imagebrush(); imagebrush.imagesource = bmp; this.textblock.foreground = imagebrush; here's how looks solidcolorbrush underline applied
then when imagebrush applied, underline gone
so question how apply imagebrush foreground underline textblock in uwp?
so question how apply imagebrush foreground underline textblock in uwp?
by default, underline removed when imagebrush has been applied textblock's foreground property.
the workaround using border simulate underline:
<border borderthickness="0, 0, 0, 2" height="{binding actualheight, elementname=textblock}" width="{binding actualwidth, elementname=textblock}"> <border.borderbrush> <imagebrush imagesource="assets/0.jpg" /> </border.borderbrush> <textblock x:name="textblock" fontsize="50" fontweight="bold"> <textblock.foreground> <imagebrush imagesource="assets/0.jpg" /> </textblock.foreground> <underline><run text="this text"/></underline> </textblock> </border> you can create usercontrol/customcontrol maintain reusability.



Comments
Post a Comment