我正在使用以下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>
你能到達終點其他方式的字符串(滾動條,滾輪等)? – XAMeLi