简体   繁体   中英

WPF: Change LineHeight property of RIchTextBox

First I must say that I am a beginner at .net and WPF. So now I am having a problem setting a LineHeight property of a RichTextBox. But if I write LineHeight="10" in XAML file it says : The member "LineHeight" is not recognized or is not accessible. I would like to find a way to set it like in TextBox.

XAML code:

<StackPanel Orientation="Vertical">
    <RichTextBox Width="auto" LineHeight="12"  HorizontalAlignment="Left" FontSize="14" Padding="0" Margin="0" Background="Transparent" Name="LabelContent" IsReadOnly="true" BorderThickness="0" IsDocumentEnabled="True" FontFamily="Calibri"/>
    <Label HorizontalAlignment="Right" Padding="0,0,0,0" Name="LabelDate" Margin="0" FontSize="10" Foreground="{Binding TimeTextBrush}" Content="Feb Tue, 12:35" />
</StackPanel>

Maybe this woks:

 <RichTextBox Block.LineHeight="2"/>

Or this:

<RichTextBox>
    <RichTextBox.Resources>
        <Style TargetType="{x:Type Paragraph}">
            <Setter Property="Margin" Value="0,10,0,0"/>
        </Style>
    </RichTextBox.Resources>
</RichTextBox>

Or this:

RichTextBox rtb = new RichTextBox();
rtb.SetValue(Paragraph.LineHeightProperty, 1.0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM