In an application I work on, a developer has recently added replaced a couple regular Microsoft multiline textboxes with Telerik RichTextBoxes. In one instance, it works fine. In another instance the line breaks after several characters so it appears on the UI as typing like:
This is an
example of what is happening when typing |
What may be causing this unintended line break? This is the code implemented in this instance:
private const string XamlMultilineTextBox =
"<telerik:RadRichTextBox xmlns=\"{0}\" xmlns:telerik=\"{1}\" xmlns:x=\'{3}\' xmlns:rtf=\"clr-namespace:Telerik.Windows.Documents.FormatProviders.Txt;assembly=Telerik.Windows.Documents\" x:Name=\"RTFBox\" Height=\"48\" VerticalScrollBarVisibility=\"Auto\" Margin=\"0\" VerticalContentAlignment=\"Stretch\" FontFamily=\"Segoe UI\" FontSize=\"12\" FontStyle=\"Normal\" IsSpellCheckingEnabled=\"False\" FontWeight=\"Normal\" DocumentInheritsDefaultStyleSettings=\"True\"><telerik:RadRichTextBox.Resources><rtf:TxtDataProvider x:Key=\"RtfDataProvider\" RichTextBox=\"{{Binding ElementName=RTFBox}}\" Text=\"{{Binding {2}, Mode=TwoWay}}\" /></telerik:RadRichTextBox.Resources></telerik:RadRichTextBox>";
private static UIElement BuildMultiLineTextBox(MultilineTextBoxDescriptor descriptor)
{
var propertyName = descriptor.PropertyName;
var output = string.Format(XamlMultilineTextBox, DefaultNamespace, TelerikNamespace, propertyName, winfxNamespace);
// ReSharper disable JoinDeclarationAndInitializer
UIElement ctrl;
// ReSharper restore JoinDeclarationAndInitializer
#if SILVERLIGHT
ctrl = (UIElement)XamlReader.Load(output);
#else
ctrl = (UIElement)XamlReader.Parse(output);
#endif
var multilineTextBox = (RadRichTextBox)ctrl;
multilineTextBox.IsSelectionMiniToolBarEnabled = false;
multilineTextBox.LayoutMode=DocumentLayoutMode.Flow;
multilineTextBox.TabIndex = descriptor.TabIndex;
multilineTextBox.ShowFormattingSymbols = false;
multilineTextBox.IsContextMenuEnabled = false;
multilineTextBox.SetBinding(RadRichTextBox.IsReadOnlyProperty,
new Binding
{
Path =
new PropertyPath(GetIsReadOnlyPropertyName(descriptor.PropertyName)),
Mode = BindingMode.TwoWay
});
multilineTextBox.SetBinding(UIElement.VisibilityProperty,
new Binding
{
Path =
new PropertyPath(GetIsVisiblePropertyName(descriptor.PropertyName)),
Mode = BindingMode.TwoWay,
Converter = new BoolToVisibilityConverter(),
ConverterParameter = descriptor.PropertyName
});
return ctrl;
}
Thank you,
John