Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lblcolorfrom.Content = "Colour From: " + colourChange.ElementAt(3).Value.ToUpper();
- <TextBlock.Inlines>
- <Run FontWeight="Bold" FontSize="14" Text="This is WPF TextBlock Example. " />
- <Run FontStyle="Italic" Foreground="Red" Text="This is red text. " />
- </TextBlock.Inlines>
- <TextBlock.Inlines>
- <Run FontWeight="Bold" FontSize="14" Text="{Binding BoldText}" />
- <Run FontStyle="Italic" Foreground="Red" Text="{Binding ItalicText}" />
- </TextBlock.Inlines>
- <TextBlock.Inlines>
- <Run FontWeight="{Binding Weight}"
- FontSize="{Binding Size}"
- Text="{Binding LineOne}" />
- <Run FontStyle="{Binding Style}"
- Foreground="Binding Colour}"
- Text="{Binding LineTwo}" />
- </TextBlock.Inlines>
- <TextBlock>
- Hello <Bold>my</Bold> faithful <Underline>computer</Underline>.<Italic>You rock!</Italic>
- </TextBlock>
- //----------------------------------------------
- // FormatTheText.cs (c) 2006 by Charles Petzold
- //----------------------------------------------
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Documents;
- namespace Petzold.FormatTheText
- {
- class FormatTheText : Window
- {
- [STAThread]
- public static void Main()
- {
- Application app = new Application();
- app.Run(new FormatTheText());
- }
- public FormatTheText()
- {
- Title = "Format the Text";
- TextBlock txt = new TextBlock();
- txt.FontSize = 32; // 24 points
- txt.Inlines.Add("This is some ");
- txt.Inlines.Add(new Italic(new Run("italic")));
- txt.Inlines.Add(" text, and this is some ");
- txt.Inlines.Add(new Bold(new Run("bold")));
- txt.Inlines.Add(" text, and let's cap it off with some ");
- txt.Inlines.Add(new Bold(new Italic (new Run("bold italic"))));
- txt.Inlines.Add(" text.");
- txt.TextWrapping = TextWrapping.Wrap;
- Content = txt;
- }
- }
- }
- <TextBlock>
- Sample text with <Bold>bold</Bold>, <Italic>italic</Italic> and <Underline>underlined</Underline> words.
- </TextBlock>
- <TextBlock>
- Sample text with <Span FontWeight="Bold">bold</Span>, <Span FontStyle="Italic">italic</Span> and <Span TextDecorations="Underline">underlined</Span> words. <Span Foreground="Blue">Coloring</Span> <Span Foreground="Red">is</Span> <Span Background="Cyan">also</Span> <Span Foreground="Silver">possible</Span>.
- </TextBlock>
- <TextBlock>
- <Span FontStyle="Italic">Italic <Span Background="Yellow">text</Span> with some <Span Foreground="Blue">coloring</Span>.</Span>
- </TextBlock>
- <TextBlock>
- Username: <Run FontWeight="Bold" Text="{Binding UserName}"/>
- </TextBlock>
- TextBlock tb = new TextBlock();
- tb.Inlines.Add("Sample text with ");
- tb.Inlines.Add(new Run("bold") { FontWeight = FontWeights.Bold });
- tb.Inlines.Add(", ");
- tb.Inlines.Add(new Run("italic ") { FontStyle = FontStyles.Italic });
- tb.Inlines.Add("and ");
- tb.Inlines.Add(new Run("underlined") { TextDecorations = TextDecorations.Underline });
- tb.Inlines.Add("words.");
- <TextBlock Margin="10" TextWrapping="Wrap">
- TextBlock with <Bold>bold</Bold>, <Italic>italic</Italic> and <Underline>underlined</Underline> text.
- </TextBlock>
- <TextBlock Margin="10" TextWrapping="Wrap">
- This <Span FontWeight="Bold">is</Span> a
- <Span Background="Silver" Foreground="Maroon">TextBlock</Span>
- with <Span TextDecorations="Underline">several</Span>
- <Span FontStyle="Italic">Span</Span> elements,
- <Span Foreground="Blue">
- using a <Bold>variety</Bold> of <Italic>styles</Italic>
- </Span>.
- </TextBlock>
- <TextBlock TextWrapping="Wrap" Style="{DynamicResource InstructionStyle}">
- <Run Text="This wizard will take you through the purge process in the correct order." FontWeight="Bold" />
- <LineBreak />
- <Run x:Name="InstructionSectionOne" Text="To Begin, select" FontStyle="Italic" />
- <Run x:Name="InstructionSectionTwo" Text="'Text Replaced At Runtime'" FontWeight="Bold"/>
- <Run x:Name="InstructionSectionThree" Text="from the menu." FontWeight="Bold" />
- </TextBlock>
Add Comment
Please, Sign In to add comment