1

次の TextBox スタイルを使用しています。TextBox に入力し続けると、テキストが長くなりすぎるとキャレットまでスクロールしません。また、ドラッグしてテキストをスクロールすることもできません。何か不足していますか?

<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Background" Value="{StaticResource TextBoxBackgroundBrush}"/>
    <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorderBrush}"/>
    <Setter Property="BorderThickness" Value="2"/>
    <Setter Property="FontSize" Value="26"/>
    <Setter Property="TextWrapping" Value="Wrap"/>
    <Setter Property="MaxLines" Value="1"/>
    <Setter Property="Padding" Value="5"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Height" Value="50"/>
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type TextBox}">
                <Grid>
                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                     Background="{TemplateBinding Background}" CornerRadius="2" SnapsToDevicePixels="true">
                        <Border.Effect>
                            <DropShadowEffect Direction="-90" ShadowDepth="2"/>
                        </Border.Effect>
                    </Border>
                    <Border BorderBrush="{TemplateBinding BorderBrush}" x:Name="GlowBd" BorderThickness="2" CornerRadius="2" SnapsToDevicePixels="true">
                        <Border.Effect>
                            <DropShadowEffect Direction="360" BlurRadius="6" ShadowDepth="0"/>
                        </Border.Effect>
                    </Border>
                    <Grid Margin="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <ContentControl Content="{TemplateBinding Tag}"/>
                        <ScrollViewer Grid.Column="1" Margin="{TemplateBinding Padding}" x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                </Grid>
                <!-- Some triggers -->
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
4

2 に答える 2

0

この場合の ScrollViewer のコンテンツはテキストであるため、テキストでスクロールさせたい場合は、ScrollViewer の CanContentScroll プロパティを設定します...

<ScrollViewer Grid.Column="1" Margin="{TemplateBinding Padding}" x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CanContentScroll="True" />
于 2013-10-17T22:19:34.873 に答える