This is a migrated thread and some comments may be shown as answers.

White space is not wrapping in Flow Layout Mode

1 Answer 103 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 02 Dec 2010, 08:05 PM
So while testing my code, I noticed that if I type a random string of characters into the text box, it wraps as it should, but if I type just white space it will continue on the same line indefinitely, until I type some non whitespace character, which then wraps to the other side.  After doing so, I also loose all my default page margins.  I replicated the issue in a small solution.  It's below.

The Xaml

<UserControl x:Class="RichTextBoxTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:dHTML="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <!-- This is necessary for binding the RadRichTextBox to the MessageHtml Property.  Do not remove, even if marked as never used.-->
        <dHTML:HtmlDataProvider x:Key="xamlDataProvider"
                                RichTextBox="{Binding ElementName=_rrtbMessage}"
                                SetupDocument="SetupMessage"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">

        <Controls:RadRichTextBox x:Name="_rrtbMessage" HorizontalAlignment="Stretch" Margin="200,100,200,100" VerticalAlignment="Stretch" BorderThickness="1" Background="White" IsSelectionMiniToolBarEnabled="False" DocumentInheritsDefaultStyleSettings="True" FontSize="11" BorderBrush="Black" />

    </Grid>
</UserControl>
<UserControl x:Class="RichTextBoxTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:dHTML="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <!-- This is necessary for binding the RadRichTextBox to the MessageHtml Property.  Do not remove, even if marked as never used.-->
        <dHTML:HtmlDataProvider x:Key="xamlDataProvider"
                                RichTextBox="{Binding ElementName=_rrtbMessage}"
                                SetupDocument="SetupMessage"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">

        <Controls:RadRichTextBox x:Name="_rrtbMessage" HorizontalAlignment="Stretch" Margin="200,100,200,100" VerticalAlignment="Stretch" BorderThickness="1" Background="White" IsSelectionMiniToolBarEnabled="False" DocumentInheritsDefaultStyleSettings="True" FontSize="11" BorderBrush="Black" />

    </Grid>
</UserControl>
<UserControl x:Class="RichTextBoxTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:dHTML="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <!-- This is necessary for binding the RadRichTextBox to the MessageHtml Property.  Do not remove, even if marked as never used.-->
        <dHTML:HtmlDataProvider x:Key="xamlDataProvider"
                                RichTextBox="{Binding ElementName=_rrtbMessage}"
                                SetupDocument="SetupMessage"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">

        <Controls:RadRichTextBox x:Name="_rrtbMessage" HorizontalAlignment="Stretch" Margin="200,100,200,100" VerticalAlignment="Stretch" BorderThickness="1" Background="White" IsSelectionMiniToolBarEnabled="False" DocumentInheritsDefaultStyleSettings="True" FontSize="11" BorderBrush="Black" />

    </Grid>
</UserControl>
<UserControl x:Class="RichTextBoxTest.MainPage"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:dHTML="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents.FormatProviders.Html" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <!-- This is necessary for binding the RadRichTextBox to the MessageHtml Property.  Do not remove, even if marked as never used.-->
        <dHTML:HtmlDataProvider x:Key="xamlDataProvider"
                                RichTextBox="{Binding ElementName=_rrtbMessage}"
                                SetupDocument="SetupMessage"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
 
        <Controls:RadRichTextBox x:Name="_rrtbMessage" HorizontalAlignment="Stretch" Margin="200,100,200,100" VerticalAlignment="Stretch" BorderThickness="1" Background="White" IsSelectionMiniToolBarEnabled="False" DocumentInheritsDefaultStyleSettings="True" FontSize="11" BorderBrush="Black" />
 
    </Grid>
</UserControl>

The C#

using System.Windows.Controls;
using Telerik.Windows.Documents.FormatProviders;
using Telerik.Windows.Documents.Layout;
using Telerik.Windows.Documents.Model;
 
namespace RichTextBoxTest
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
 
        private void SetupMessage(object sender, SetupDocumentEventArgs e)
        {
            e.Document.LayoutMode = DocumentLayoutMode.Flow;
            e.Document.ParagraphDefaultSpacingAfter = 0;
            e.Document.SectionDefaultPageMargin = new Padding(5, 3, 3, 5);
        }
    }
}

Is there anything I can do to prevent this?  In my original program I've also had a problem with the text being shifted to the left past the boarder of the text box sometimes when I select all, but not always.  I think this problem may be related, but I'm not sure and I wasn't able to replicate it so I'll keep trying there.

Thanks,
Michael

1 Answer, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 06 Dec 2010, 01:30 PM
Hi Michael,

Thank you for getting to us about this misbehavior that you have noticed. We have already fixed this issue and you can download the first LIB that comes out, which resolves this.
If you have any other questions, do not hesitate to contact us again.

Greetings,
Iva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or