UWP应用程序中的Scrollviewer无法正常工作

时间:2016-04-04 11:43:17

标签: windows-phone-8 scrollview win-universal-app

我在横向模式下有一个页面,在代码中设置下一行:

DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped | DisplayOrientations.Landscape;

以下是全屏模式的代码:

Windows.UI.ViewManagement.ApplicationView view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
view.TryEnterFullScreenMode();

在我的滚动查看器中,我想要包含一些来自syncfusion包的动态创建的图表。
我认为这是问题,但过了一段时间,我尝试在网格中创建一些只包含文本块的行我可以尝试滚动查看器,它也不起作用。

这是我的所有页面内容(page和page.resources内容除外):

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="auto"/>
        <RowDefinition Height="auto"/>
        <RowDefinition Height="auto"/>
        <RowDefinition />
    </Grid.RowDefinitions>
    <StackPanel Background="{StaticResource AccentBrush}" Grid.Row="0" Margin="0,0,0,10">
        <TextBlock Name="Statistic_name" HorizontalAlignment="Center" FontSize="23" Text="Estadísticas"/>
    </StackPanel>
    <StackPanel Grid.Row="1" Margin="15,0,15,0">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ComboBox Grid.Column="0" Name="Combo_device" PlaceholderText="Contenedor" SelectionChanged="Combo_device_SelectionChanged" />
            <ComboBox Grid.Column="1" Name="Combo_sensor" PlaceholderText="Sensor" />
            <ComboBox Grid.Column="2" Name="Combo_number" PlaceholderText="Número" />
            <!-- SelectionChanged="Combo_number_SelectionChanged" -->
            <Button Name="Show_data" Grid.Column="3" Click="Show_data_Button_Click" Content="Cargar Datos"/>
        </Grid>
    </StackPanel>
    <StackPanel Grid.Row="2">
        <ScrollViewer  Margin="20,20,20,20" Name="Scroll_container" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" >
            <Grid Name="Stack_panel_scroll_statistics">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0">Hola 0</TextBlock>
                <TextBlock Grid.Row="1">Hola 1</TextBlock>
                <TextBlock Grid.Row="2">Hola 2</TextBlock>
                <TextBlock Grid.Row="3">Hola 3</TextBlock>
                <TextBlock Grid.Row="4">Hola 4</TextBlock>
                <TextBlock Grid.Row="5">Hola 5</TextBlock>
                <TextBlock Grid.Row="6">Hola 6</TextBlock>
                <TextBlock Grid.Row="7">Hola 7</TextBlock>
                <TextBlock Grid.Row="8">Hola 8</TextBlock>
                <TextBlock Grid.Row="9">Hola 9</TextBlock>
                <TextBlock Grid.Row="10">Hola 10</TextBlock>
                <TextBlock Grid.Row="11">Hola 11</TextBlock>
                <TextBlock Grid.Row="12">Hola 12</TextBlock>
                <TextBlock Grid.Row="13">Hola 13</TextBlock>
                <TextBlock Grid.Row="14">Hola 14</TextBlock>
                <TextBlock Grid.Row="15">Hola 15</TextBlock>
                <TextBlock Grid.Row="16">Hola 16</TextBlock>
                <TextBlock Grid.Row="17">Hola 17</TextBlock>
            </Grid>
        </ScrollViewer>
    </StackPanel>
</Grid>

有人可以告诉我错误在哪里吗?

我尝试了很多修改代码,结果总是一样的。我认为这是因为内容是在C#部分动态创建的,但在尝试使用文本块之后,似乎并非如此。

1 个答案:

答案 0 :(得分:1)

将包含滚动查看器的<RowDefinition Height="auto"/>的{​​{1}}更改为Grid.Row=2或指定滚动查看器的最小高度。

修改
删除Stackpanel也只需使用Scrollviewer

工作代码

<RowDefinition Height="*"/>