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,我不知道出了什么问题

4

2 回答 2

3

嗨,在我再次遇到同样的问题后,我能够解决这个问题

您可以使用样式进行简单更改,但前提是 FontSize 不固定

不会工作

    <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>
于 2013-12-18T07:37:24.003 回答
0

拿着这个:

        <FlowDocumentScrollViewer >
            <FlowDocument FontSize="50">
                <Paragraph>
                    this text should be FontSize 56
                </Paragraph>
            </FlowDocument>
        </FlowDocumentScrollViewer>
于 2013-03-18T09:56:24.710 回答