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.
精彩评论