I have had this concern in the past and wrote my own converter to handle the process of Kearning.
Converter Class
internal class KearningConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
string result = value.ToString();
try {
int length = int.Parse(parameter.ToString());
if (result.Length > length) {
result = result.Substring(0, length) + "...";
}
} catch {
result += "...";
}
return result;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
throw new NotImplementedException();
}
}
Xaml Markup
xmlns:conv="clr-namespace:project.converters;assembly=project"
<Window.Resources>
<conv:KearningConverter x:Key="kearnConverter"/>
</Window.Resources>
<TextBlock Text="{Binding Path=AttributeName, Converter={StaticResource kearnConverter}, ConverterParameter=3}"/>
This way you can have multiple implementations of the kearning based on different requirements depening on the layout of your UI.