2013-10-31 128 views
3

我開發了小企業的應用程序,我有水平滾動瀏覽器的問題。的ScrollViewer XAML:鼠標滾輪不工作

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

出了什麼問題?

+0

你可以發佈XAML,任何可能相關的代碼,以及*完全*什麼不工作的描述嗎? – ZombieSheep

回答

4

除了確保您的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> 
+1

謝謝!!!!!!!!!!!!!!!!!!!!!! 它工作正常 – Chrism4111

+0

對我而言,我失蹤的關鍵部分是將VerticalScrollBarVisibility設置爲Disabled。我將它設置爲自動,並且這樣做,通過鼠標滾輪進行水平滾動不起作用。 –

0

嘗試減少網格寬度,然後檢查。通常,如果網格寬度較大或「自動」,內容會自動縮放以適應,因此scrollviewer不起作用。