Guest User

Untitled

a guest
Sep 26th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. lblcolorfrom.Content = "Colour From: " + colourChange.ElementAt(3).Value.ToUpper();
  2.  
  3. <TextBlock.Inlines>
  4. <Run FontWeight="Bold" FontSize="14" Text="This is WPF TextBlock Example. " />
  5. <Run FontStyle="Italic" Foreground="Red" Text="This is red text. " />
  6. </TextBlock.Inlines>
  7.  
  8. <TextBlock.Inlines>
  9. <Run FontWeight="Bold" FontSize="14" Text="{Binding BoldText}" />
  10. <Run FontStyle="Italic" Foreground="Red" Text="{Binding ItalicText}" />
  11. </TextBlock.Inlines>
  12.  
  13. <TextBlock.Inlines>
  14. <Run FontWeight="{Binding Weight}"
  15. FontSize="{Binding Size}"
  16. Text="{Binding LineOne}" />
  17. <Run FontStyle="{Binding Style}"
  18. Foreground="Binding Colour}"
  19. Text="{Binding LineTwo}" />
  20. </TextBlock.Inlines>
  21.  
  22. <TextBlock>
  23. Hello <Bold>my</Bold> faithful <Underline>computer</Underline>.<Italic>You rock!</Italic>
  24. </TextBlock>
  25.  
  26. //----------------------------------------------
  27. // FormatTheText.cs (c) 2006 by Charles Petzold
  28. //----------------------------------------------
  29. using System;
  30. using System.Windows;
  31. using System.Windows.Controls;
  32. using System.Windows.Input;
  33. using System.Windows.Media;
  34. using System.Windows.Documents;
  35.  
  36. namespace Petzold.FormatTheText
  37. {
  38. class FormatTheText : Window
  39. {
  40. [STAThread]
  41. public static void Main()
  42. {
  43. Application app = new Application();
  44. app.Run(new FormatTheText());
  45. }
  46. public FormatTheText()
  47. {
  48. Title = "Format the Text";
  49.  
  50. TextBlock txt = new TextBlock();
  51. txt.FontSize = 32; // 24 points
  52. txt.Inlines.Add("This is some ");
  53. txt.Inlines.Add(new Italic(new Run("italic")));
  54. txt.Inlines.Add(" text, and this is some ");
  55. txt.Inlines.Add(new Bold(new Run("bold")));
  56. txt.Inlines.Add(" text, and let's cap it off with some ");
  57. txt.Inlines.Add(new Bold(new Italic (new Run("bold italic"))));
  58. txt.Inlines.Add(" text.");
  59. txt.TextWrapping = TextWrapping.Wrap;
  60.  
  61. Content = txt;
  62. }
  63. }
  64. }
  65.  
  66. <TextBlock>
  67. Sample text with <Bold>bold</Bold>, <Italic>italic</Italic> and <Underline>underlined</Underline> words.
  68. </TextBlock>
  69.  
  70. <TextBlock>
  71. 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>.
  72. </TextBlock>
  73.  
  74. <TextBlock>
  75. <Span FontStyle="Italic">Italic <Span Background="Yellow">text</Span> with some <Span Foreground="Blue">coloring</Span>.</Span>
  76. </TextBlock>
  77.  
  78. <TextBlock>
  79. Username: <Run FontWeight="Bold" Text="{Binding UserName}"/>
  80. </TextBlock>
  81.  
  82. TextBlock tb = new TextBlock();
  83. tb.Inlines.Add("Sample text with ");
  84. tb.Inlines.Add(new Run("bold") { FontWeight = FontWeights.Bold });
  85. tb.Inlines.Add(", ");
  86. tb.Inlines.Add(new Run("italic ") { FontStyle = FontStyles.Italic });
  87. tb.Inlines.Add("and ");
  88. tb.Inlines.Add(new Run("underlined") { TextDecorations = TextDecorations.Underline });
  89. tb.Inlines.Add("words.");
  90.  
  91. <TextBlock Margin="10" TextWrapping="Wrap">
  92. TextBlock with <Bold>bold</Bold>, <Italic>italic</Italic> and <Underline>underlined</Underline> text.
  93. </TextBlock>
  94.  
  95. <TextBlock Margin="10" TextWrapping="Wrap">
  96. This <Span FontWeight="Bold">is</Span> a
  97. <Span Background="Silver" Foreground="Maroon">TextBlock</Span>
  98. with <Span TextDecorations="Underline">several</Span>
  99. <Span FontStyle="Italic">Span</Span> elements,
  100. <Span Foreground="Blue">
  101. using a <Bold>variety</Bold> of <Italic>styles</Italic>
  102. </Span>.
  103. </TextBlock>
  104.  
  105. <TextBlock TextWrapping="Wrap" Style="{DynamicResource InstructionStyle}">
  106. <Run Text="This wizard will take you through the purge process in the correct order." FontWeight="Bold" />
  107. <LineBreak />
  108. <Run x:Name="InstructionSectionOne" Text="To Begin, select" FontStyle="Italic" />
  109. <Run x:Name="InstructionSectionTwo" Text="'Text Replaced At Runtime'" FontWeight="Bold"/>
  110. <Run x:Name="InstructionSectionThree" Text="from the menu." FontWeight="Bold" />
  111. </TextBlock>
Add Comment
Please, Sign In to add comment