我强调'任何'的原因是因为CanContentScroll我的工作没有充分发挥作用ScollViewer.让我解释一下这个场景:我有一个ScrollViewer标签,后面跟ListBox各个标签.我之所以有这个内容的原因ScrollViewer是因为我不希望每个ListBox人都有一个ScrollBar,我只想要一个"全球" ScrollBar.问题是,当光标在在ListBox在ScrollViewer不滚动.我试图CanContentScroll在ScrollViewer,ListBox和ListBoxItem样式中将属性设置为true,但没有成功.我应该使用其他控件类型吗?这是我的代码示例:
<UserControl x:Class="Telbit.TeStudio.View.Controls.TestStepsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Telbit.TeStudio.View.Controls">
<UserControl.Resources>
<DataTemplate DataType="{x:Type my:TestStepsStepViewModel}">
<my:TestStepsStepView HorizontalAlignment="Stretch"/>
</DataTemplate>
<Style x:Key="StepItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Name="Border" SnapsToDevicePixels="true" Background="Transparent" BorderThickness="0" Padding="1">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="Background" Value="#40a0f5ff"/>
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="IsSelected" …Run Code Online (Sandbox Code Playgroud)