<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.Window1"
Title="TextTrimming Sample">
<DockPanel Margin="10">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,0,0,25">
<Button Click="ttNone">TextTrimming="None"</Button>
<Button Click="ttCE">TextTrimming="CharacterEllipsis"</Button>
<Button Click="ttWE">TextTrimming="WordEllipsis"</Button>
</StackPanel>
<TextBlock Name="txt1" DockPanel.Dock="Bottom"/>
<TextBlock HorizontalAlignment="Left" TextWrapping="NoWrap"
Width="400" FontFamily="Arial" Name="tf1" DockPanel.Dock="Top"
Background="SkyBlue">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt
laoreet dolore magna aliquam erat volutpat.
</TextBlock>
</DockPanel>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Namespace WpfApplication1
Public Partial Class Window1
Inherits Window
Public Sub ttNone(sender As Object, e As RoutedEventArgs)
tf1.TextTrimming = System.Windows.TextTrimming.None
txt1.Text = "TextTrimming is now " + tf1.TextTrimming.ToString()
End Sub
Public Sub ttCE(sender As Object, e As RoutedEventArgs)
tf1.TextTrimming = System.Windows.TextTrimming.CharacterEllipsis
txt1.Text = "TextTrimming is now " + tf1.TextTrimming.ToString()
End Sub
Public Sub ttWE(sender As Object, e As RoutedEventArgs)
tf1.TextTrimming = System.Windows.TextTrimming.WordEllipsis
txt1.Text = "TextTrimming is now " + tf1.TextTrimming.ToString()
End Sub
End Class
End Namespace
|