Your question asked about BINDING a string in WPF (without altering the internal content of the string), and among the preferred strategies for solving this is to use a converter, here's an example that does what you're looking for (display the first 10 characters only)...
public class CodeConverter : MarkupExtension, IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
try
{
string result = value.ToString();
if (result.Length > 10)
{
// code in your exact requirements here...
return result.Substring(0, 10);
}
return result;
}
catch{}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
return null;
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
In your Xaml, simply specify this class in your binding...
{Binding Code, Converter={StaticResource CodeConverter}
And you're good to go!