Is there a click behavior for a list?

…衆ロ難τιáo~ 提交于 2019-11-30 14:22:12

问题


I have a list view, on a panoramic control. I've also created an event for MouseLeftButtonUp however I find that when scrolling between the panorama items the MousLeftButtonUp is triggering (it makes sense why but it is unexpected from a user perspective).

Is there any way to create a click event for a list? Or add a behavior that simulates that?


回答1:


Checkout the Tap gesture from the Gesture service that's part of the toolkit.

WP7 Tip of the Day: Silverlight Toolkit: Gestures

    <ListBox Height="100" HorizontalAlignment="Left" Margin="12,186,0,0" Name="listBox1" VerticalAlignment="Top" Width="460" >
        <Controls:GestureService.GestureListener>
            <Controls:GestureListener Tap="GestureListener_Tap">
            </Controls:GestureListener>
        </Controls:GestureService.GestureListener>
        <ListBoxItem Content="1"/>
        <ListBoxItem Content="2"/>
        <ListBoxItem Content="3"/>
        <ListBoxItem Content="4"/>
    </ListBox>

and

public void GestureListener_Tap(object sender, GestureEventArgs e) {
    System.Diagnostics.Debug.WriteLine("tap");
}



回答2:


The listbox should already accept contact, so you can just fire the SelectionChanged event



来源:https://stackoverflow.com/questions/4637793/is-there-a-click-behavior-for-a-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!