段落边框在FlowDocument内部显得模糊,SnapsToDevicePixels和UseLayoutRounding都不起作用

时间:2013-03-31 12:20:05

标签: c# .net wpf xaml

当我使用BorderThickness属性在Paragraph中的FlowDocument内的FlowDocumentScrollViewer元素上绘制边框时,边框似乎模糊有时。

这是我的代码段。

<Grid>
    <FlowDocumentScrollViewer>
        <FlowDocument>
            <Paragraph BorderBrush="Black" BorderThickness="0.5">This is a paragraph</Paragraph>
            <Paragraph BorderBrush="Black" BorderThickness="0.5">This is a paragraph</Paragraph>
            <Paragraph BorderBrush="Black" BorderThickness="0.5">This is a paragraph</Paragraph>
        </FlowDocument>
    </FlowDocumentScrollViewer>
</Grid>

我尝试将SnapsToDevicePixels="True"UseLayoutRounding="True"放在GridFlowDocumentScrollViewer上(因为Paragraph本身不支持这些属性),但没有任何事情发生。

这个问题仍然是个问题吗?如果没有,我该如何解决?

1 个答案:

答案 0 :(得分:3)

<Grid RenderOptions.EdgeMode="Aliased">
        <FlowDocumentScrollViewer>
            <FlowDocument>
                <Paragraph Margin="2" BorderBrush="Black" BorderThickness=".5">This is a paragraph</Paragraph>
                <Paragraph Margin="2" BorderBrush="Black" BorderThickness=".5">This is a paragraph</Paragraph>
                <Paragraph Margin="2" BorderBrush="Black" BorderThickness=".5">This is a paragraph</Paragraph>
            </FlowDocument>
        </FlowDocumentScrollViewer>
    </Grid>