XAML <TextBlock> element represents a TextBlock control.
- <TextBlock Name="TextBlock1" Height="30" Width="200"
- Text="Hello! I am a TextBlock." Foreground="Red">
- </TextBlock>
- <TextBlock Name="TextBlock1" Height="30" Width="200"
- Text="Hello! I am a TextBlock."
- Margin="10,10,0,0" VerticalAlignment="Top"
- HorizontalAlignment="Left">
- </TextBlock>
The following code example sets TextBlock's font including font name, font size, and font styles.
- FontSize="14" FontFamily="Verdana" FontWeight="Bold"
- TextWrapping="Wrap"
- TextAlignment="Right"
- <TextBlock Name="TextBlock1" Height="30" Width="200"
- Text="Hello! I am a TextBlock." Foreground="Red"
- Margin="10,10,0,0" VerticalAlignment="Top"
- HorizontalAlignment="Left"
- FontSize="14" FontFamily="Verdana" FontWeight="Bold"
- TextWrapping="Wrap" TextAlignment="Center" Padding="2">
- </TextBlock>
- <Run FontWeight="Bold" FontSize="14" Text="Hi! I am a TextBlock. " />
- <Run FontStyle="Italic" Foreground="Red" Text="This is red text. " />
- <Run FontStyle="Italic" FontSize="18" Text="Here is some linear gradient text. ">
- <Run.Foreground>
- <LinearGradientBrush>
- <GradientStop Color="Green" Offset="0.0" />
- <GradientStop Color="Purple" Offset="0.25" />
- <GradientStop Color="Orange" Offset="0.5" />
- <GradientStop Color="Blue" Offset="0.75" />
- </LinearGradientBrush>
- </Run.Foreground>
- </Run>
- <Run FontStyle="Italic" Foreground="Green" Text="How about adding some green? " />
- </TextBlock.Inlines>

Vithal WadjePosted Jan 10, 2015, 1:57 PM
nice,thanks for sharing