2012-01-18 78 views
-2

我有一個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> 
+0

我只是想要禮貌.... – Subby 2012-01-18 20:11:35

回答

1

取而代之的是MouseLeftButtonDown事件,使用Tap事件。看到這是Silverlight的標籤,我假設你的意思是Windows Phone而不是Windows Mobile

+0

嘿那裏。謝謝你的評論。我在我的XML中輸入「Tap」,但它不能識別它。有任何想法嗎? – Subby 2012-01-18 21:17:07

+0

你的意思是'XAML' :)而'Tap'是圖像控件的一個事件http://msdn.microsoft.com/en-us/library/system.windows.controls.image%28VS.95%29.aspx它拋出了什麼錯誤? – keyboardP 2012-01-18 21:19:52

+0

啊對,XAML,對不起:) 那麼,我在Image標籤中鍵入Tap =「eventHandler」,它不能識別Tap。然後我檢查了圖像控件中的事件列表,它沒有水龍頭......它有像GotFocus,MouseLeave,MouseEnter,Loaded,LeftButton等等的東西,但沒有水龍頭。 – Subby 2012-01-18 21:25:01