简体   繁体   中英

ScrollViewer XAML : MouseWheel Not Working

I'm developing an application for a small business and I have a problem with the Horizontal Scroll Viewer.

Horizontal ScrollViewer appears on the screen but the mouse wheel doesn't work.

I Have this XAML Code:

<ScrollViewer ScrollViewer.ZoomMode="Disabled" HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto" ScrollViewer.IsHorizontalScrollChainingEnabled="True" VerticalScrollBarVisibility="Disabled" Margin="0,130,0,0" VerticalContentAlignment="Stretch" ManipulationMode="All">
       <Grid Width="1000" HorizontalAlignment="Left" >
           <Grid.ColumnDefinitions>
               <ColumnDefinition Width="250*" ></ColumnDefinition>
               <ColumnDefinition Width="250*"/>
               <ColumnDefinition Width="250*"/>
               <ColumnDefinition Width="250*"/>
           </Grid.ColumnDefinitions>
           <Grid.RowDefinitions>
               <RowDefinition Height="65*" />
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
               <RowDefinition Height="45*"/>
           </Grid.RowDefinitions>
           <TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,0,0" Text="Στοιχεία Πελάτη" FontSize="50"></TextBlock>
           <TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Όνομα :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Επώνυμο :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Τηλέφωνο :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Κινητό :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="0" Grid.Row="5" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Διεύθυνση :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="0" Grid.Row="6" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Πόλη :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Χώρα :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="2" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Email :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="2" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Α.Φ.Μ :" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="2" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center" Text="ΔΟΥ:" FontSize="30"></TextBlock>
           <TextBlock Grid.Column="2" Grid.Row="5" HorizontalAlignment="Right" VerticalAlignment="Center" Text="Περιγραφή:" FontSize="30"></TextBlock>
           <TextBox Grid.Column="1" Grid.Row="1" Height="30"></TextBox>
           <TextBox Grid.Column="1" Grid.Row="2" Height="30"></TextBox>
           <TextBox Grid.Column="1" Grid.Row="3" Height="30"></TextBox>
           <TextBox Grid.Column="1" Grid.Row="4" Height="30"></TextBox>
           <TextBox Grid.Column="1" Grid.Row="5" Height="30"></TextBox>
           <TextBox Grid.Column="1" Grid.Row="6" Height="30"></TextBox>
           <TextBox Grid.Column="3" Grid.Row="1" Height="30"></TextBox>
           <TextBox Grid.Column="3" Grid.Row="2" Height="30"></TextBox>
           <TextBox Grid.Column="3" Grid.Row="3" Height="30"></TextBox>
           <TextBox Grid.Column="3" Grid.Row="4" Height="30" VerticalAlignment="Center"></TextBox>
           <TextBox Grid.Column="3" Grid.Row="5" Grid.RowSpan="4" AcceptsReturn="True" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Visible"/>
           <Button Grid.Column="3" Grid.Row="9" Content="Αποθήκευση" FontSize="22" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Button>
      </Grid>
   </ScrollViewer>

What could be wrong?

In addition to making sure your scrollviewer is being presented at a fixed width, therefore enabling scrolling within the viewer itself (it currently looks like the viewer doesn't need to scroll to display the content), change the viewer declaration to the following.

 <ScrollViewer 
    Style="{StaticResource HorizontalScrollViewerStyle}"
    ScrollViewer.IsHorizontalScrollChainingEnabled="True" 
    Margin="0,130,0,0" 
    VerticalContentAlignment="Stretch" 
    ManipulationMode="All">

The style should be defined in StandardStyles.xaml, but if you aren't using that file, the definition is as follows.

<Style x:Key="HorizontalScrollViewerStyle" TargetType="ScrollViewer">
    <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
    <Setter Property="VerticalScrollBarVisibility" Value="Disabled"/>
    <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled" />
    <Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />
    <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
</Style>

Try reducing the grid width and then check. Usually, if grid width is large or 'auto' the content automatically scales to fit and hence scrollviewer doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM