其他分享
首页 > 其他分享> > ScrollViewer XAML:MouseWheel无法正常工作

ScrollViewer XAML:MouseWheel无法正常工作

作者:互联网

我正在为一家小型企业开发应用程序,但是水平滚动查看器存在问题.

屏幕上出现水平ScrollViewer,但鼠标滚轮不起作用.

我有此XAML代码:

<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>

有什么事吗

解决方法:

除了确保以固定的宽度显示滚动查看器之外,还可以在查看器内部进行滚动(当前看来查看器不需要滚动显示内容),还可以将查看器声明更改为以下内容.

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

样式应该在StandardStyles.xaml中定义,但是如果您不使用该文件,则定义如下.

<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>

标签:windows-store,scrollviewer,xaml,c
来源: https://codeday.me/bug/20191030/1966459.html