0
我試圖爲我的文本框創建樣式,但是當我將此模板添加到垂直滾動條消失的樣式時。TextBox樣式不創建垂直滾動條
<Style x:Key="MyTextBoxStyle" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="{DynamicResource BlueForegroundBrush}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="0,-5,0,0"/>
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="100"/>
<Setter Property="Focusable" Value="True"/>
<Setter Property="AllowDrop" Value="True"/>
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Rectangle x:Name="_rct" Stroke="#FFA8AFBE" RadiusX="8" RadiusY="8" Fill="White" />
<Border x:Name="_borderActive" BorderThickness="2" CornerRadius="8" BorderBrush="#FFA8AFBE" >
<ListBox x:Name="Bd" SnapsToDevicePixels="true"
Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="6">
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ListBox>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>