Windows Mobile - ScrollViewer
我有一个 Windows Mobile 应用程序。在该应用程序中,我有一个 ScrollViewer,它允许用户浏览滚动条内的许多图像。在这种情况下,它们是字母表的图像。
问题是,我希望当用户单击图像时执行逻辑代码,但是,如果用户通过单击字母滚动,它会启动代码......
例如, imageA 有LeftClickButton 事件,但是...如果用户通过触摸字母 A 进行滚动...imgA_LeftClick 中的逻辑代码将触发。
我该如何克服这个问题?下面是我的代码。
<ScrollViewer Height="98" Name="scrollerButtons" Width="603" Canvas.Left="40" Canvas.Top="383" VerticalAlignment="Center" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible">
<StackPanel Name="stackPanelButtons" Orientation="Horizontal" Canvas.Left="162" Canvas.Top="43" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Height="60" Name="imgA" Source="a.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgK" Source="k.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgM" Source="m.png" Stretch="Fill" Width="60" MouseLeftButtonDown="imgM_MouseLeftButtonDown"></Image>
<Image Height="60" Name="imgJ" Source="j.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgN" Source="n.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgO" Source="o.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgI" Source="i.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgH" Source="h.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgG" Source="g.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgF" Source="f.png" Stretch="Fill" Width="60" MouseLeftButtonDown="imgF_MouseLeftButtonDown"></Image>
<Image Height="60" Name="imgE" Source="e.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgD" Source="d.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgC" Source="c.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgB" Source="b.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgL" Source="l.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgT" Source="t.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgS" Source="s.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgR" Source="r.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgQ" Source="q.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgP" Source="p.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgU" Source="u.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgZ" Source="z.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgV" Source="v.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgW" Source="w.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgY" Source="y.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgX" Source="x.png" Stretch="Fill" Width="60"></Image>
</StackPanel>
</ScrollViewer>
I have a Windows Mobile application. Within that application, i've got a ScrollViewer which allows the user to flick through the many images which I have inside that scroller. In this case, they are images of the alphabet.
The problem is, I want logical code to execute when the user clicks on an image, BUT, if the user scrolls by clicking on the letter, it actuates the code....
For example, imageA has a LeftClickButton event, but...if the user scrolls by touching the letter A....the logical code in the imgA_LeftClick fires.
How do I overcome this problem? Below is my code.
<ScrollViewer Height="98" Name="scrollerButtons" Width="603" Canvas.Left="40" Canvas.Top="383" VerticalAlignment="Center" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible">
<StackPanel Name="stackPanelButtons" Orientation="Horizontal" Canvas.Left="162" Canvas.Top="43" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Height="60" Name="imgA" Source="a.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgK" Source="k.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgM" Source="m.png" Stretch="Fill" Width="60" MouseLeftButtonDown="imgM_MouseLeftButtonDown"></Image>
<Image Height="60" Name="imgJ" Source="j.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgN" Source="n.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgO" Source="o.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgI" Source="i.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgH" Source="h.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgG" Source="g.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgF" Source="f.png" Stretch="Fill" Width="60" MouseLeftButtonDown="imgF_MouseLeftButtonDown"></Image>
<Image Height="60" Name="imgE" Source="e.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgD" Source="d.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgC" Source="c.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgB" Source="b.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgL" Source="l.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgT" Source="t.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgS" Source="s.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgR" Source="r.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgQ" Source="q.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgP" Source="p.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgU" Source="u.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgZ" Source="z.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgV" Source="v.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgW" Source="w.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgY" Source="y.png" Stretch="Fill" Width="60"></Image>
<Image Height="60" Name="imgX" Source="x.png" Stretch="Fill" Width="60"></Image>
</StackPanel>
</ScrollViewer>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 点击 事件。鉴于它被标记为 Silverlight,我假设您指的是
Windows Phone
而不是Windows Mobile
。Instead of the
MouseLeftButtonDown
event, use the Tap event. Seeing as this is tagged Silverlight, I assume you meanWindows Phone
and notWindows Mobile
.