Windows Mobile - ScrollViewer

发布于 2024-12-27 15:14:58 字数 3692 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2025-01-03 15:14:58

使用 点击 事件。鉴于它被标记为 Silverlight,我假设您指的是 Windows Phone 而不是 Windows Mobile

Instead of the MouseLeftButtonDown event, use the Tap event. Seeing as this is tagged Silverlight, I assume you mean Windows Phone and not Windows Mobile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文