2017-08-08 12 views
2

ComboBoxドロップダウンで自動スクロール効果を無効にすることはできますか?問題は、マウスが開いている最後の要素の上にマウスを置いたときに自動的に次の要素にスクロールします。ComboBoxコンボボックス(WPF)でのマウスオーバーのスクロールを無効にする

そして、私の場合には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> 

私はScrollViewer.CanContentScroll="False"を設定しようとしましたが、それは動作しませんでした。

これは、次のようになります。

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

あなたの助けをありがとう!あなたがComboBoxItemコンテナのRequestBringIntoViewイベントを処理することができ

+0

実際に働いていたあなたの質問 – Ben

答えて

1

<ComboBox> 
    <ComboBox.ItemContainerStyle> 
     <Style TargetType="ComboBoxItem"> 
      <EventSetter Event="RequestBringIntoView" Handler="ComboBox_RequestBringIntoView"/> 
     </Style> 
    </ComboBox.ItemContainerStyle> 
</ComboBox> 

private void ComboBox_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e) 
{ 
    e.Handled = true; 
} 
+0

に例を追加してください!助けてくれてありがとう :) – smithmartin

関連する問題