views:

597

answers:

1

Hi there, Im trying to make a recreation of MSWord using WPF RichTextBox and Toolbar, so one of the recently issues is the following:

In MSWord document...

...with Font Family Times New Roman, 11, Justify a single line contains 95 Chars ...with Font Family Times New Roman, 11, Justify, Bold a single line contains 83 Chars

about margins It will be more recommended to work with margins or limit chars per line? Cause when user inputs are , . or anothers ASCII wich size is shorter than others ones, the max chars in single line "Changes". So if use margins is most propertly - how the WPF RichTextBox manage margins ?

Thanks!

+1  A: 

Trying to limit characters per line sounds like a nightmare to me. You're better off getting rid of the default ControlTemplate for RichTextBox so you just have the text, then setting the Margin on your RichTextBox so the text "floats" in the middle:

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
    <ScrollViewer>
        <RichTextBox Margin="30,0">
            <RichTextBox.Template>
                <ControlTemplate TargetType="{x:Type RichTextBox}">
                    <Border x:Name="PART_ContentHost" Margin="2" Background="Transparent" BorderBrush="Transparent"/>
                </ControlTemplate>
            </RichTextBox.Template>
        </RichTextBox>
    </ScrollViewer>
</Grid>
Robert Macnee