簡體   English   中英

ScrollViewer XAML:MouseWheel不工作

[英]ScrollViewer XAML : MouseWheel Not Working

我正在開發一個小型企業的應用程序,我遇到了水平滾動查看器的問題。

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

嘗試減小網格寬度,然后檢查。 通常,如果網格寬度很大或“自動”,則內容會自動縮放以適應,因此scrollviewer不起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM