我有这样的代码,增加了虚线在文本框中的文本下:如何格式化WPF中的特定文本?
// Create an underline text decoration. Default is underline.
TextDecoration myUnderline = new TextDecoration();
// Create a linear gradient pen for the text decoration.
Pen myPen = new Pen();
myPen.Brush = new LinearGradientBrush(Colors.White, Colors.White, new Point(0, 0.5), new Point(1, 0.5));
myPen.Brush.Opacity = 0.5;
myPen.Thickness = 1.0;
myPen.DashStyle = DashStyles.Dash;
myUnderline.Pen = myPen;
myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
// Set the underline decoration to a TextDecorationCollection and add it to the text block.
TextDecorationCollection myCollection = new TextDecorationCollection();
myCollection.Add(myUnderline);
PasswordSendMessage.TextDecorations = myCollection;
我的问题是,我需要在文本中只有最后6个字符被格式化!
任何想法我怎么能做到这一点?
'TextBlock.Inlines'不是一个依赖属性,所以不幸的是你不能使用数据绑定绑定它。 – Quartermeister 2010-09-07 12:35:38
哦,应该看了起来。在这种情况下,人们总是可以走附加的道具路线。 – MrDosu 2010-09-08 07:11:31