2013-05-31 31 views
5

リストボックスでscrollviewerを使用しているとき、リストボックスの最後にタッチスクロール。マウスホイールを使用すると、この動作は表示されません。このオーバースケール/ゴムバンド効果/スナップバック効果/バウンス効果を無効にするにはどうすればよいですか?xaml Scrollviewer - ウィンドウ全体のオーバースケール/ラバーバンド効果/スナップバック効果/バウンスを無効にする

私はWindows 8コンピュータで.NET Framework 4.5を使用しています。あなたはこのビデオでバウンス効果を見ることができます

:ここhttp://www.vidup.de/v/gQ2pI/

は私のサンプルコードです:

<Window x:Class="style_test_for_scrollviewer.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525"> 

    <Grid> 
     <ListBox Width="200"> 
      <WrapPanel Width="200"  ScrollViewer.PanningMode="VerticalOnly"   ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible"> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
       <Button Height="200" Width="200"></Button> 
     </WrapPanel> 
     </ListBox> 
    </Grid> 
</Window> 

答えて

4

あなたはOnManipulationBoundaryFeedbackメソッドをオーバーライドすることで、この動作を削除することができます

public class FixedListBox : ListBox 
{ 
    protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e) 
    { 
     e.Handled = true; 
    } 
} 

他の解決策は、ManipulationBoundaryFeedbackイベント(ListBox上またはスタイルを使用して直接)に次のハンドラを追加することです。

<ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback"/> 

または:の後ろに次のコードで

<Style TargetType="{x:Type ListBox}"> 
    <EventSetter Event="ManipulationBoundaryFeedback" Handler="OnManipulationBoundaryFeedback"/> 
</Style> 

protected void OnManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e) 
{ 
    e.Handled = true; 
} 

これらの方法あまりにもScrollViewerので動作します。