如何使段落角变圆?
How can I make a paragraph corners round?
我有一个富文本框,我可以(动态地)向其中添加段落,
我想在添加段落时使段落边框变圆,我该怎么做?
这是我的代码:
<Grid>
<RichTextBox x:Name="richTextBox" HorizontalAlignment="Left" Height="315" Margin="10,10,0,0" VerticalAlignment="Top" Width="312" IsReadOnly="True" >
<FlowDocument x:Name="flowDocument" >
</FlowDocument>
</RichTextBox>
</Grid>
我尝试访问段落边框 属性,但我做不到。
我的代码中有这样的内容:
Paragraph p = new Paragraph(new Run("Some text"));
p.BorderBrush = Brushes.Black;
p.BorderThickness = new Thickness(1);
//Make the paragraph border round
flowDoucment.Blocks.Add(p);
知道如何设置边框的 CornerRadius
属性 吗?
您可以通过以下方式进行:
<Border Height="315" Width="312" BorderBrush="Bisque" VerticalAlignment="Top" Margin="10,10,0,0" HorizontalAlignment="Left" BorderThickness="2" CornerRadius="20">
<RichTextBox x:Name="richTextBox" Height="315" VerticalAlignment="Bottom" BorderThickness="0" Width="312" IsReadOnly="True" >
</RichTextBox>
</Border>
<Border Height="315" Width="312" BorderBrush="Bisque" VerticalAlignment="Top" Margin="10,10,0,0" HorizontalAlignment="Left" BorderThickness="2" CornerRadius="20" />
您可以使用 BlockUIContainer 并在其中再添加一个 RichTextBox 来实现它。参考下面的代码。
<RichTextBox>
<FlowDocument>
<BlockUIContainer>
<Border BorderThickness="2" BorderBrush="Blue" CornerRadius="8" Padding="3">
<RichTextBox BorderThickness="0">
<FlowDocument>
<Paragraph>This is paragraph with border</Paragraph>
</FlowDocument>
</RichTextBox>
</Border>
</BlockUIContainer>
</FlowDocument>
</RichTextBox>
我有一个富文本框,我可以(动态地)向其中添加段落, 我想在添加段落时使段落边框变圆,我该怎么做? 这是我的代码:
<Grid>
<RichTextBox x:Name="richTextBox" HorizontalAlignment="Left" Height="315" Margin="10,10,0,0" VerticalAlignment="Top" Width="312" IsReadOnly="True" >
<FlowDocument x:Name="flowDocument" >
</FlowDocument>
</RichTextBox>
</Grid>
我尝试访问段落边框 属性,但我做不到。
我的代码中有这样的内容:
Paragraph p = new Paragraph(new Run("Some text"));
p.BorderBrush = Brushes.Black;
p.BorderThickness = new Thickness(1);
//Make the paragraph border round
flowDoucment.Blocks.Add(p);
知道如何设置边框的 CornerRadius
属性 吗?
您可以通过以下方式进行:
<Border Height="315" Width="312" BorderBrush="Bisque" VerticalAlignment="Top" Margin="10,10,0,0" HorizontalAlignment="Left" BorderThickness="2" CornerRadius="20">
<RichTextBox x:Name="richTextBox" Height="315" VerticalAlignment="Bottom" BorderThickness="0" Width="312" IsReadOnly="True" >
</RichTextBox>
</Border>
<Border Height="315" Width="312" BorderBrush="Bisque" VerticalAlignment="Top" Margin="10,10,0,0" HorizontalAlignment="Left" BorderThickness="2" CornerRadius="20" />
您可以使用 BlockUIContainer 并在其中再添加一个 RichTextBox 来实现它。参考下面的代码。
<RichTextBox>
<FlowDocument>
<BlockUIContainer>
<Border BorderThickness="2" BorderBrush="Blue" CornerRadius="8" Padding="3">
<RichTextBox BorderThickness="0">
<FlowDocument>
<Paragraph>This is paragraph with border</Paragraph>
</FlowDocument>
</RichTextBox>
</Border>
</BlockUIContainer>
</FlowDocument>
</RichTextBox>