Wednesday, May 23, 2012

How to make WPF Text Block under line and change its fore color programmatically in C#


 TextDecoration _textDecorationUderLine = new TextDecoration();
             Pen _pen = new Pen();
            _pen.Brush = new LinearGradientBrush(Colors.Blue, Colors.Blue, new Point(0, 0.5), new Point(1, 0.5));
            _pen.DashStyle = DashStyles.Solid;
            _textDecorationUderLine.Pen = _pen;
            _textDecorationUderLine.PenThicknessUnit = TextDecorationUnit.FontRecommended;
            TextDecorationCollection _textDecorationCollection = new TextDecorationCollection();
            _textDecorationCollection.Add(_textDecorationUderLine);
            tbPreferredPhoneWork.TextDecorations = _textDecorationCollection;
            tbPreferredPhoneWork.Foreground = Brushes.Blue;

No comments:

Post a Comment