滚动条无法在UWP中运行

时间:2017-09-30 17:48:25

标签: uwp scrollview scrollbar visual-studio-2017 vertical-scrolling

<Pivot Margin="10,0,0,0">
            <PivotItem  HorizontalAlignment="Stretch" Padding="0,5,10,0"  Header="New User Info">
                <ScrollViewer IsVerticalScrollChainingEnabled="True" VerticalScrollMode="Enabled">
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <StackPanel x:Name="U_BasicInfo" Background="SkyBlue" CornerRadius="20" 
                                       Grid.ColumnSpan="2" Grid.RowSpan="2" HorizontalAlignment="Stretch">
                            <TextBlock x:Name="BasicInfoHeader" Text="Basic Info" FontSize="25"
                                      Margin="20,20,0,0"/>
                            <Image x:Name="UserPSImage" Visibility="Collapsed" Height="150" Width="150"/>
                            <Button x:Name="ChooseImage_Button"
                                Content="Choose File" Click="ChooseImageButton_Click" HorizontalAlignment="Center"/>
                            <TextBox x:Name="U_UserID" IsEnabled="False" Header="UserID" Margin="20,0,20,0"
                                           FontSize="20"/>
                            <TextBox x:Name="U_FirstName" PlaceholderText="Enter FirstName"
                                       Margin="20,10,20,0" RelativePanel.Below="U_UserID" TextChanged="U_FirstName_TextChanged"/>
                            <TextBox x:Name="U_MiddleName" PlaceholderText="Enter MiddleName"
                                         RelativePanel.Below="U_FirstName" Margin="20,10,20,0"/>
                            <TextBox x:Name="U_LastName" PlaceholderText="Enter LastName" TextChanged="U_LastName_TextChanged"
                                         RelativePanel.Below="U_MiddleName" Margin="20,10,20,0"/>
                            <DatePicker x:Name="U_BirthDate" RelativePanel.Below="U_LastName" Header="Birth Date"
                                            Margin="20,10,0,20" DateChanged="U_BirthDate_DateChanged"/>
                        </StackPanel>

                        <StackPanel x:Name="U_ContactInfo" Background="SkyBlue" CornerRadius="20" 
                                       Grid.ColumnSpan="2" Grid.Column="2" Margin="10,0,0,0">
                            <TextBlock x:Name="ContactHeader" Text="Contact Info" FontSize="25" Margin="20,20,0,0"/>
                            <TextBox x:Name="U_Email" PlaceholderText="Enter Email Address" Margin="20,20,20,0"/>
                            <TextBox x:Name="U_Mobile1" PlaceholderText="Enter Mobile Number" Margin="20,10,20,0"/>
                            <TextBox x:Name="U_Mobile2" PlaceholderText="Enter Mobile Number 2" Margin="20,10,20,20"/>
                        </StackPanel>


                        <StackPanel x:Name="assdd" Background="SkyBlue" CornerRadius="20" 
                                        Grid.ColumnSpan="6" Grid.Row="4" Margin="0,10,0,0">
                            <TextBlock x:Name="assdasd" Text="Attached Document" FontSize="25"
                                      Margin="20,20,0,20"/>
                            <Button x:Name="asdsafd" Content="Add User" Click="AddUserInfoButton_Click"
                            HorizontalAlignment="Stretch" FontWeight="SemiBold" Margin="20,0,20,20"/>
                        </StackPanel>
                    </Grid>
                </ScrollViewer>
            </PivotItem>
         <Pivot/>

enter image description here

此代码只是添加了一个滚动条但没有工作.....

我还添加了一个

“ScrollViewer.VerticalScrollBarVisibility =” 可见”  ScrollViewer.VerticalScrollMode = “启用”,“

但它不起作用。它也提供相同的输出..... 请告诉我缺少什么.....如何让它工作?

1 个答案:

答案 0 :(得分:0)

Pivot 有自己的水平滚动查看器,但是可以添加垂直滚动查看器。不确定您是否尝试过添加它:

<Pivot Margin="10,0,0,0">
    <PivotItem  HorizontalAlignment="Stretch" Padding="0,5,10,0"  Header="New User Info">
        <ScrollViewer>
            <Grid HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <!--Your content of the grid, sample:-->
                <Rectangle Grid.Row="0" Fill="Red" Height="300"/>
                <Rectangle Grid.Row="1" Fill="Green" Height="300"/>
                <Rectangle Grid.Row="2" Fill="Blue" Height="300"/>
            </Grid>
        </ScrollViewer>
    </PivotItem>
</Pivot>

仅供参考 - 如果您正在阅读 ScrollViewers (可能不是这里的情况),请查看Vertical/Horizontal chaining values