小编smi*_*tin的帖子

在 ComboBox (WPF) 中禁用鼠标悬停滚动

是否可以在ComboBox下拉菜单中禁用自动滚动效果?问题是当鼠标悬停在打开的最后一个元素上时,ComboBox它会自动滚动到下一个元素。

就我而言,ComboBox它位于屏幕底部,列表向上显示,当我打开ComboBox并移动鼠标时,它立即向下滚动。我的 XAML 如下所示:

<ComboBox x:Name="serverSelection" ScrollViewer.CanContentScroll="False" Width="268" Height="54" FontSize="18" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" SelectedIndex="0">
    <ComboBoxItem Content="xenappts01" HorizontalAlignment="Left" Width="280" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
    <ComboBoxItem Content="xenappts02" HorizontalAlignment="Left" Width="280" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
    <ComboBoxItem Content="xenappts03" HorizontalAlignment="Left" Width="280" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
    <ComboBoxItem Content="xenappts04" HorizontalAlignment="Left" Width="280" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
    <ComboBoxItem Content="xenappts05" HorizontalAlignment="Left" Width="280" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
    <ComboBoxItem Content="xenappts05c" HorizontalAlignment="Left" Width="280" Height="54" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)

我试图设置,ScrollViewer.CanContentScroll="False"但没有奏效。

这是它的样子:

https://i.stack.imgur.com/GcwJX.gif

谢谢你的帮助!

c# wpf visual-studio-2017

4
推荐指数
1
解决办法
1835
查看次数

标签 统计

c# ×1

visual-studio-2017 ×1

wpf ×1