Effects of the enumerated values of TextWrapping. : TextBlock « Windows Presentation Foundation « C# / CSharp Tutorial






<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="WpfApplication1.Window1" Height="480" Width="640"
  Title="TextWrap Sample">
  <StackPanel Margin="0,0,0,10" Background="LightSkyBlue">
    <StackPanel Orientation="Horizontal" Margin="0,0,0,20">
      <Button Name="btn1" Background="Silver" Width="100" Click="Wrap">Wrap</Button>
      <Button Name="btn2" Background="Silver" Width="100" Click="NoWrap">NoWrap</Button>
      <Button Name="btn4" Background="Silver" Width="100" Click="WrapWithOverflow">WrapWithOverflow</Button>
    </StackPanel>
    <TextBlock Name="txt2" TextWrapping="Wrap" Margin="0,0,0,20" Foreground="Black">
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Lorem ipsum dolor sit amet, 
      consectetuer adipiscing elit.Lorem ipsum dolor sit aet, consectetuer adipiscing elit.
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
    </TextBlock>
    <TextBlock FontSize="12" Name="txt1">
      The TextWrap property is currently set to Wrap.
    </TextBlock>    
  </StackPanel>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace WpfApplication1
{

  public partial class Window1 : Window
  {
        public void Wrap(object sender, RoutedEventArgs e)
        {
            txt2.TextWrapping = System.Windows.TextWrapping.Wrap;
            txt1.Text = "The TextWrap property is currently set to Wrap.";
        }
        public void NoWrap(object sender, RoutedEventArgs e)
        {
            txt2.TextWrapping = System.Windows.TextWrapping.NoWrap;
            txt1.Text = "The TextWrap property is currently set to NoWrap.";
        }
        public void WrapWithOverflow(object sender, RoutedEventArgs e)
        {
            txt2.TextWrapping = System.Windows.TextWrapping.WrapWithOverflow;
            txt1.Text = "The TextWrap property is currently set to WrapWithOverflow.";
        }
    }
}
WPF Effects Of The Enumerated Values Of Text Wrapping








24.7.TextBlock
24.7.1.TextBlock VerticalAlignmentTextBlock VerticalAlignment
24.7.2.TextBlock ScaleTransform ScaleXTextBlock ScaleTransform ScaleX
24.7.3.TextBlock ScaleTransform ScaleY and TransformGroupTextBlock ScaleTransform ScaleY and TransformGroup
24.7.4.Adding Hyperlink to TextBlockAdding Hyperlink to TextBlock
24.7.5.Spell Check a TextBox or RichTextBox Control in Real TimeSpell Check a TextBox or RichTextBox Control in Real Time
24.7.6.Set TextBlock.FontSize for GridSet TextBlock.FontSize for Grid
24.7.7.Add TextBlock into a GridAdd TextBlock into a Grid
24.7.8.Intrinsic character direction in TextBlockIntrinsic character direction in TextBlock
24.7.9.Mixed character directions and TextBlockMixed character directions and TextBlock
24.7.10.FlowDirection of TextBlockFlowDirection of TextBlock
24.7.11.Use RenderTransform to transform a TextBlockUse RenderTransform to transform a TextBlock
24.7.12.Use LayoutTransform to transform a TextBlockUse LayoutTransform to transform a TextBlock
24.7.13.Set Margins for TextBlock in Grid ResourceSet Margins for TextBlock in Grid Resource
24.7.14.Set TextWrapping to True for TextBlockSet TextWrapping to True for TextBlock
24.7.15.Set ToolTip text for TextBlockSet ToolTip text for TextBlock
24.7.16.Set Text value for TextBlockSet Text value for TextBlock
24.7.17.Set Foreground color for TextBlockSet Foreground color for TextBlock
24.7.18.Add Border to TextBlockAdd Border to TextBlock
24.7.19.Put Rectangle into TextBlockPut Rectangle into TextBlock
24.7.20.Programmatically change the way in which TextBlock is trimmed when it exceeds the outer boundaries of its containing box.Programmatically change the way in which TextBlock is trimmed when it exceeds the outer boundaries of its containing box.
24.7.21.Effects of the enumerated values of TextWrapping.Effects of the enumerated values of TextWrapping.
24.7.22.VerticalAlignment=Top HorizontalAlignment=LeftVerticalAlignment=Top  HorizontalAlignment=Left