滚动到Windows Phone 7中的特定位置 [英] Scrolling to a particular position in windows phone 7

查看:52
本文介绍了滚动到Windows Phone 7中的特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有两个xaml页面。 page1有10个按钮,第2页有10个图像放在水平scrollviewer中。当我点击按钮时它应该滚动到那个图像。我在这里发布我的代码。



MainPage.xaml



< pre lang =xml> < 网格 x:名称 = ContentPanel Grid.Row = 1 保证金 = 12,0,12,0 >
< ScrollViewer VerticalScrollBarVisibility = 自动 >
< 工具包:WrapPanel >

< 按钮 BorderBrush = {x:Null} 点击 = Button_Click 名称 = button1 >
< StackPanel >
< 图像 名称 = image1 来源 = / PhoneApp3;组件/rhymes/10inabed.png\" 拉伸 = 填写 高度 = 100 宽度 = 150 / >
< / StackPanel >
< /按钮 >
< 按钮 < span class =code-attribute>宽度 = 210 BorderBrush = {x:Null} 点击 = Button_Click_1 名称 = < span class =code-keyword> button2 >
< StackPanel >
< 图像 名称 = image2 来源 = / PhoneApp3; component / rhymes / abcsong.png 保证金 = 10 高度 = 100 宽度 = 156 / >
< ; / StackPanel >
< /按钮 >
< 按钮 BorderBrush = {x:Null} 点击 = Button_Click_2 名称 = button3 >
< StackPanel >
< 图像 名称 = image3 来源 = / PhoneApp3; component / rhymes / baabaablacksheep.png 拉伸 = 填写 < span class =code-attribute>高度 = 100 宽度 = 150 / >
< / StackPanel >
< /按钮 >
< 按钮 宽度 = 210 BorderBrush = {x:Null} 点击 = Button_Click_3 名称 = button4 >
< StackPanel >
< 图像 名称 = image4 来源 = / PhoneApp3; component / rhymes / chubbycheeks.png 保证金 = 10 高度 = 100 宽度 = 156 / >
< / StackPanel >
< /按钮 >
< 按钮 BorderBrush = {x:Null} 单击 = Button_Click_4 名称 = < span class =code-keyword> button5 >
< StackPanel >
< 图像 名称 = image5 来源 = / PhoneApp3; component / rhymes / daysoftheweek.png 拉伸 = 填充 高度 = 100 宽度 = 150 / >
< / StackPanel >
< /按钮 >
< 按钮 宽度 = 210 BorderBrush = {x:Null} 单击 = Button_Click_5 名称 = < span class =code-keyword> button6 &g t;
< StackPanel >
< 图片 名称 = image6 来源 = / PhoneApp3; component / rhymes / fruittrain.png 保证金 = 10 高度 = 100 Wid th = 156 / >
< / StackPanel >
< /按钮 >
< 按钮 < span class =code-attribute> BorderBrush = {x:Null} 点击 = Button_Click_6 名称 = button7 >
< StackPanel >
< 图片 名称 = image7 来源 = / PhoneApp3; component / rhymes / happybirthday.png 拉伸 = 填写 高度 = 100 宽度 = 150 / >
< / StackPanel >
< /按钮 >
< 按钮 < span class =code-attribute>宽度 = 210 BorderBrush = {x:Null} 单击 = Button_Click_7 名称 = button8 >
< StackPanel >
< 图像 名称 = image8 来源 = / PhoneApp3; component / rhymes / hickorydickory.png 保证金 = 10 高度 = 100 宽度 = 156 / >
< / StackPanel >
< /按钮 >
< 按钮 BorderBrush = {x:Null} 点击 = Button_Click_8 名称 = button9 >
< StackPanel >
< 图像 名称 = image9 来源 = / PhoneApp3; component / rhymes / HumptyDumpty.png 拉伸 = 填写 高度 = 100 宽度 = 150 / >
< / StackPanel >
< /按钮 >
< 按钮 宽度 = 210 BorderBrush = {x:Null} 点击 = Button_Click_9 名称 = button10 >
< StackPanel >
< 图片 名称 = image10 来源 = / PhoneApp3; component / rhymes / incywincyspider.png 保证金 = 10 高度 = 100 < span class =code-attribute> 宽度 = 156 / >
< / StackPanel >
< / toolkit:WrapPanel >

< / ScrollViewer >

< / Grid >







page1.xaml < br $>


 <   StackPanel    保证金  = < span class = code-keyword> 12,0,12,0 >  
< ScrollViewer VerticalScrollBarVisibility = 已禁用 Horizo​​ntalScrollBarVisibility = 隐藏 x:名称 = PageScrollViews >
< ScrollViewer.Background >
< ImageBrush ImageSource = / PhoneApp3; component / images / bg.png / >
< / ScrollViewer.Background >
< < span class =code-leadattribute> Grid Margin = 0,300,0,0 VerticalAlignment = Top Horizo​​ntalAlignment = x:名称 = Grid1 >

< 图片 名称 = image1 来源 = / PhoneApp3; component / images / 10InABedImg.png 高度 = 500 宽度 = 480 Horizo​​ntalAlignment = VerticalAlignment = Top 保证金 = 0,0,480,102 / >
< 图片 名称 = image2 所以urce = / PhoneApp3; component / rhymes / abcsong.png 高度 = 500 宽度 = 480 Horizo​​ntalAlignment = VerticalAlignment = Top 保证金 = 480,0,0,102 标记 = 2 / >
< 图像 名称 = image3 来源 = / PhoneApp3; component / rhymes / baabaablacksheep.png 高度 = 500 宽度 = 480 Horizo​​ntalAlignment = VerticalAlignment = Top 保证金 = 960,0,0,102 / >
<Image Name=\"image4\" Source=\"/PhoneApp3 ;component/rhymes/chubbycheeks.png\" Height=\"500\" Width=\"480\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"1440,0,0,102\"/>
<Image Name=\"image5\" Source=\"/PhoneApp3;component/rhymes/daysoftheweek.png\" Height=\"500\" Width=\"480\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"1920,0,0,102\"/>
<Image Name=\"image6\" Source=\"/PhoneApp3;component/rhymes/fruittrain.png\" Height=\"500\" Width=\"480\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"2400,0,0,102\"/>
<Image Name=\"image7\" Source=\"/PhoneApp3;component/rhymes/happybirthday.png\" Height
=\"500\" Width=\"480\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"2880,0,0,102\"/>
<Image Name=\"image8\" Source=\"/PhoneApp3;component/rhymes/hickorydickory.png\" Height=\"500\" Width=\"480\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"< span class=\"code-keyword\">3360,0,0,102\"/>
<Image Name=\"image9\" Source=\"/PhoneApp3;component/rhymes/HumptyDumpty.png\" Height=\"500\" Width=\"480\" HorizontalAlignment=\"
Left\" VerticalAlignment=\"Top\" Margin=\"3840,0,0,102\"/>
<Image Name=\"image10\" Source=\"/PhoneApp3;component/rhymes/incywincyspider.png\" Height=\"500\" Width=\"480\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" Margin=\"4320,0,0,102\"/>



</Grid> 
</ScrollViewer>
</StackPanel>





how to scroll to particular image on button click from previous page

解决方案

please check this.





displaying a image in Image slide in windows phone 7[^]


Hi,

I have two xaml pages . page1 having 10 buttons and page two having 10 images placed in horizontal scrollviewer.when i click on button it should scroll to that image. I am posting my code here.

MainPage.xaml

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
           <ScrollViewer VerticalScrollBarVisibility="Auto">
               <toolkit:WrapPanel>

                   <Button BorderBrush="{x:Null}" Click="Button_Click" Name="button1">
                       <StackPanel>
                           <Image Name="image1" Source="/PhoneApp3;component/rhymes/10inabed.png" Stretch="Fill" Height="100" Width="150" />
                       </StackPanel>
                   </Button>
                   <Button Width="210" BorderBrush="{x:Null}" Click="Button_Click_1" Name="button2">
                       <StackPanel>
                           <Image Name="image2"  Source="/PhoneApp3;component/rhymes/abcsong.png" Margin="10" Height="100" Width="156"  />
                       </StackPanel>
                   </Button >
                   <Button BorderBrush="{x:Null}" Click="Button_Click_2" Name="button3">
                       <StackPanel>
                           <Image Name="image3" Source="/PhoneApp3;component/rhymes/baabaablacksheep.png" Stretch="Fill" Height="100" Width="150" />
                       </StackPanel>
                   </Button>
                   <Button Width="210" BorderBrush="{x:Null}" Click="Button_Click_3" Name="button4">
                       <StackPanel>
                           <Image Name="image4" Source="/PhoneApp3;component/rhymes/chubbycheeks.png" Margin="10" Height="100" Width="156"  />
                       </StackPanel>
                   </Button>
                   <Button BorderBrush="{x:Null}" Click="Button_Click_4" Name="button5">
                       <StackPanel>
                           <Image Name="image5" Source="/PhoneApp3;component/rhymes/daysoftheweek.png" Stretch="Fill" Height="100" Width="150" />
                       </StackPanel>
                   </Button>
                   <Button Width="210" BorderBrush="{x:Null}" Click="Button_Click_5" Name="button6">
                       <StackPanel>
                           <Image Name="image6" Source="/PhoneApp3;component/rhymes/fruittrain.png" Margin="10" Height="100" Width="156"  />
                       </StackPanel>
                   </Button>
                   <Button BorderBrush="{x:Null}" Click="Button_Click_6" Name="button7">
                       <StackPanel>
                           <Image Name="image7" Source="/PhoneApp3;component/rhymes/happybirthday.png" Stretch="Fill" Height="100" Width="150" />
                       </StackPanel>
                   </Button>
                   <Button Width="210" BorderBrush="{x:Null}" Click="Button_Click_7" Name="button8">
                       <StackPanel>
                           <Image Name="image8" Source="/PhoneApp3;component/rhymes/hickorydickory.png" Margin="10" Height="100" Width="156"  />
                       </StackPanel>
                   </Button>
                   <Button BorderBrush="{x:Null}" Click="Button_Click_8" Name="button9">
                       <StackPanel>
                           <Image Name="image9" Source="/PhoneApp3;component/rhymes/HumptyDumpty.png" Stretch="Fill" Height="100" Width="150" />
                       </StackPanel>
                   </Button>
                   <Button Width="210" BorderBrush="{x:Null}" Click="Button_Click_9" Name="button10">
                       <StackPanel>
                           <Image Name="image10" Source="/PhoneApp3;component/rhymes/incywincyspider.png" Margin="10" Height="100" Width="156"  />
                       </StackPanel>
</toolkit:WrapPanel>

            </ScrollViewer>

        </Grid>




page1.xaml

<StackPanel Margin="12,0,12,0">
       <ScrollViewer VerticalScrollBarVisibility ="Disabled" HorizontalScrollBarVisibility="Hidden" x:Name="PageScrollViews">
           <ScrollViewer.Background>
               <ImageBrush ImageSource="/PhoneApp3;component/images/bg.png" />
           </ScrollViewer.Background>
           <Grid Margin="0,300,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="Grid1">

               <Image Name="image1" Source="/PhoneApp3;component/images/10InABedImg.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,480,102"  />
               <Image Name="image2" Source="/PhoneApp3;component/rhymes/abcsong.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="480,0,0,102" Tag="2" />
               <Image Name="image3" Source="/PhoneApp3;component/rhymes/baabaablacksheep.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="960,0,0,102"/>
               <Image Name="image4" Source="/PhoneApp3;component/rhymes/chubbycheeks.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1440,0,0,102"/>
               <Image Name="image5" Source="/PhoneApp3;component/rhymes/daysoftheweek.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1920,0,0,102"/>
               <Image Name="image6" Source="/PhoneApp3;component/rhymes/fruittrain.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2400,0,0,102"/>
               <Image Name="image7" Source="/PhoneApp3;component/rhymes/happybirthday.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2880,0,0,102"/>
               <Image Name="image8" Source="/PhoneApp3;component/rhymes/hickorydickory.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3360,0,0,102"/>
               <Image Name="image9" Source="/PhoneApp3;component/rhymes/HumptyDumpty.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3840,0,0,102"/>
               <Image Name="image10" Source="/PhoneApp3;component/rhymes/incywincyspider.png" Height="500" Width="480" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="4320,0,0,102"/>


</Grid>
        </ScrollViewer>
    </StackPanel>



how to scroll to particular image on button click from previous page

解决方案

please check this.


displaying a image in Image slide in windows phone 7[^]


这篇关于滚动到Windows Phone 7中的特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆