質問

Can anyone help me in performing vertical scrolling in my project ? I am unable to do so can someone help me in enabling that ? Here is my xaml code

    <Grid x:Name="LayoutRoot" Background="Black">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Text="Launchers" Grid.ColumnSpan="2" Margin="9,-12,-236,0" Style="{StaticResource PhoneTextTitle1Style}" Height="85" Foreground="White" FontWeight="ExtraBold" FontStretch="SemiCondensed"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"/>
        <toolkit:HubTile x:Name="GuidanceButton" HorizontalAlignment="Left"  
         VerticalAlignment="Top" Grid.Column="0" Grid.Row="1"  Background="#FF12AFC7" GroupTag="StaticHubTile" Tap="Button_gridbut_Click" Margin="30,10,0,0" Size="Medium" Source="/Images/sharemedium.png" />
        <toolkit:HubTile x:Name="JourneyButton" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Height="169" Width="169" Margin="72,230,-1,0" Grid.ColumnSpan="2" Tap="Button_gridbut_Click" Source="/Images/facebook.png"/>
        <toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,99,-1,0" Height="82" Width="82"/>
        <toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,45,148,0" Height="82" Width="82"/>
        <toolkit:HubTile x:Name="searchButton" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,137,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/camera.png" />
        <toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,7,148,0" Height="82" Width="82"/>
        <toolkit:HubTile x:Name="routeButton1" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,99,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/status.png" />
    </Grid>
</Grid>
役に立ちましたか?

解決

If you are using a winform you can do this to setup your panel with vertical scrolling functionality:

ScrollBar vScrollBar1 = new VScrollBar();
vScrollBar1.Dock = DockStyle.Right;
vScrollBar1.Scroll += (sender, e) => { panel1.VerticalScroll.Value = vScrollBar1.Value; };
panel1.Controls.Add(vScrollBar1);  

Additionally you can read this article about adding vertical scroll-bar in a panel:

Vertical ScrollBar in C#

他のヒント

Simply wrap scrolling content in a scrolling control like ScrollViewer:

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"/>
    <ScrollViewer>
        <toolkit:HubTile x:Name="GuidanceButton" HorizontalAlignment="Left"  
                         VerticalAlignment="Top" Grid.Column="0" Grid.Row="1"  Background="#FF12AFC7" GroupTag="StaticHubTile" Tap="Button_gridbut_Click" Margin="30,10,0,0" Size="Medium" Source="/Images/sharemedium.png" />
        <toolkit:HubTile x:Name="JourneyButton" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Height="169" Width="169" Margin="72,230,-1,0" Grid.ColumnSpan="2" Tap="Button_gridbut_Click" Source="/Images/facebook.png"/>
        <toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,99,-1,0" Height="82" Width="82"/>
        <toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,45,148,0" Height="82" Width="82"/>
        <toolkit:HubTile x:Name="searchButton" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,137,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/camera.png" />
        <toolkit:HubTile HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF298391" GroupTag="StaticHubTile" Size="Small" Margin="0,7,148,0" Height="82" Width="82"/>
        <toolkit:HubTile x:Name="routeButton1" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="2" Background="#FF12AFC7" GroupTag="StaticHubTile" Size="Default" Margin="0,99,61,0" Grid.RowSpan="2" Height="169" Width="169" Tap="Button_gridbut_Click" Source="/Images/status.png" />
    </ScrollViewer>
</Grid>

Also, remove the last RowDefinition since you are not using it and it will break your view in half.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top