开发者

Wpf textblock partial background

I need to set a marker on a derived (inherited) textblock that will give the user an indication whether text is Left Right or Center justified. Derived class has a property called justification which is an enum with Left Right and Centre values. So I want to change background color of the textBlock partially i.e. if it is Left Justified then 25% of background on the left is a different color. Len开发者_开发问答gth of the string in the text block can vary and is not static.

Putting the textblock in another element e.g. border is not an option but I am open to any other suggestions that can manipulate Textblock without changing its size to visually mark justification.


You could assign a LinearGradientBrush to the background and manipulate the colors and the offsets of the gradientstops.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜