I do not believe that WPF has a built-in ability to do this, but I could be wrong.
The code below demonstrates how you can write your own control to do this for you. This is inefficient, and it could be related to customization, including more properties for controlling the font, etc., but you get the idea:
SpacedTextBlock.cs:
public class SpacedTextBlock : Control { public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(SpacedTextBlock)); public string Text { get { return GetValue(TextProperty) as string; } set { SetValue(TextProperty, value); } } protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (Text != null) { var widthPerChar = ActualWidth / Text.Length; var currentPosition = 0d; foreach (var ch in Text) { drawingContext.DrawText(new FormattedText(ch.ToString(), CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface("Arial"), 12, Foreground), new Point(currentPosition, 0)); currentPosition += widthPerChar; } } } }
Window1.xaml:
<local:SpacedTextBlock Text="Hello"/>
Result:
alt text http://img199.imageshack.us/img199/8022/screenshotud.png
source share