Fill the overline decoration with a linear gradient brush in C# : TextBlock Style « Windows Presentation Foundation « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » TextBlock Style 
24.8.5.Fill the overline decoration with a linear gradient brush in C#
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="TextDecorationExample.Window1"
  Title="TextDecoration Example"
  Width="720"
  Height="400"
  Loaded="WindowLoaded">
  <StackPanel>

      <TextBlock Name="overlineTextBlock" FontSize="24" Width="180" VerticalAlignment="Center">The lazy dog</TextBlock>

  </StackPanel>
</Window>
//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Media;

namespace TextDecorationExample
{
    public partial class Window1 : Window
    {
         private void WindowLoaded(object sender, EventArgs e)
         {
             // Fill the overline decoration with a linear gradient brush.
             TextDecorationCollection myCollection = new TextDecorationCollection();
             TextDecoration myOverline = new TextDecoration();
             myOverline.Location = TextDecorationLocation.OverLine;

             // Set the linear gradient brush.
             Pen myPen = new Pen();
             myPen.Brush = new LinearGradientBrush(Colors.LimeGreen, Colors.Yellow, 0);
             myPen.Thickness = 3;
             myOverline.Pen = myPen;
             myOverline.PenThicknessUnit = TextDecorationUnit.FontRecommended;

             // Set the overline decoration to the text block.
             myCollection.Add(myOverline);
             overlineTextBlock.TextDecorations = myCollection;
         }

    }
}
WPF Fill The Overline Decoration With A Linear Gradient Brush In C
24.8.TextBlock Style
24.8.1.Emboss TextEmboss Text
24.8.2.Engrave TextEngrave Text
24.8.3.Text Drop ShadowText Drop Shadow
24.8.4.Empirical Tilted Text ShadowEmpirical Tilted Text Shadow
24.8.5.Fill the overline decoration with a linear gradient brush in C#Fill the overline decoration with a linear gradient brush in C#
24.8.6.Fill the baseline decoration with a linear gradient brush in C#Fill the baseline decoration with a linear gradient brush in C#
24.8.7.Fill the underline decoration with a solid color brush in C#Fill the underline decoration with a solid color brush in C#
24.8.8.Fill the strikethrough decoration with a solid color brush in C#Fill the strikethrough decoration with a solid color brush in C#
24.8.9.Simple underline decorationSimple underline decoration
24.8.10.Use Run the mark underlink TextDecorationsUse Run the mark underlink TextDecorations
24.8.11.Format Text by changing the font size
24.8.12.Change font to Italic
24.8.13.Changing font to bold
24.8.14.Combine bold and italic style
24.8.15.Wrap the text
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.