2014-01-30 22 views
0

我正在創建一個基本的應用程序來測試基於XAML的Windows 8應用程序的一些功能。防止頁面擴展在Windows 8 XAML應用程序在ScrollView內的框架

我已經創建瞭如下的結構,以簡化我的例子,但在真正的應用程序,它會更加複雜:

<Page 
    x:Name="pageRoot" 
    x:Class="ScrollingTest.Xaml.MainPage" 
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:ScrollingTest.Xaml" 
    xmlns:common="using:ScrollingTest.Xaml.Common" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
     <ScrollViewer 
      HorizontalScrollMode="Auto" 
      HorizontalScrollBarVisibility="Auto" 
      VerticalScrollMode="Disabled" 
      VerticalScrollBarVisibility="Hidden" Margin="0,0,0,10" VerticalContentAlignment="Stretch" BorderBrush="#FF0BC8FF" BorderThickness="1" Grid.Row="1" > 

       <Frame Content="Frame" Name="theFrame" Margin="100" Width="3000" BorderBrush="Red" BorderThickness="1" 
         ScrollViewer.VerticalScrollMode="Enabled" 
         ScrollViewer.VerticalScrollBarVisibility="Visible" /> 
     </ScrollViewer> 
    </Grid> 
</Page> 

的頁面,該頁面加載到Frame是高度可變的(它包含一個列表顯示)。

問題是,隨着子頁面的高度增加,ScrollViewer的高度也增加,這意味着內容被強制離開屏幕的底部。

我想實現的是父級水平滾動,然後在子頁面上使用垂直滾動。在實際的應用程序中會有很多子頁面,可能在網格中。

看起來,將框架放入ScrollViewer中會破壞框架的內部滾動功能。

如果任何人都可以讓我知道要達到我的最終結果或某些財產的更好方法,那麼我需要更改,我會非常感激。

回答

1

我最終使用從下面的註釋解決方案: XAML: Limiting size of control nested in ScrollViewer (to scroll nested within the ScrollViewer)

Height="{Binding ElementName=scrollViewer, Path=ActualHeight}" 

算不上什麼,我想爲改變方向時,這不會自動處理,但將不得不這樣做。

另一種選擇是處理頁面的SizeChanged事件並更新事件處理函數的高度(theFrame.Height = scrollViewer.ActualHeight)。這樣它也可以應對改變方向。

相關問題