FlowDocumentScrollViewer字体大小不影响FlowDocument内容的字体大小

4
请问为什么下面的代码不起作用?
<UserControl x:Class="FlowDocReader.FlowDocumentScrollViewerIssues"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

        <FlowDocumentScrollViewer FontSize="56">
            <FlowDocument>
                <Paragraph>
                    this text should be FontSize 56
                </Paragraph>
            </FlowDocument>
        </FlowDocumentScrollViewer>

</UserControl>

如您所见,FontSize并不是56,我无法弄清楚问题出在哪里。

2个回答

3

你好,当我再次遇到这个问题时,我成功地解决了它。

如果字体大小没有固定,你可以简单地使用样式来更改它。

不起作用。

    <FlowDocumentScrollViewer FontSize="56">
        <Style TargetType="{x:Type FlowDocument}">
            <Setter Property="FontSize" Value="56"/>
        </Style>
        <FlowDocument FontSize="56">
            <Paragraph>
                this text should be FontSize 56
            </Paragraph>
        </FlowDocument>
    </FlowDocumentScrollViewer>

将会工作

    <FlowDocumentScrollViewer FontSize="56">
        <Style TargetType="{x:Type FlowDocument}">
            <Setter Property="FontSize" Value="56"/>
        </Style>
        <FlowDocument>
            <Paragraph>
                this text should be FontSize 56
            </Paragraph>
        </FlowDocument>
    </FlowDocumentScrollViewer>

那么这是一个问题吗? - Evgeny Gorbovoy

0

拿走这个:

        <FlowDocumentScrollViewer >
            <FlowDocument FontSize="50">
                <Paragraph>
                    this text should be FontSize 56
                </Paragraph>
            </FlowDocument>
        </FlowDocumentScrollViewer>

谢谢,我也知道这个。但是通常情况下我的代码应该可以工作,因为例如 FontWeight 是有效的。 - WiiMaxx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接