DataBoundListBox and Contextmenu Tap & Hold

5 posts, 1 answers
  1. Bernhard König
    Bernhard König avatar
    78 posts
    Member since:
    Nov 2009

    Posted 09 Aug 2011 Link to this post

    Hello,

    during tests with the current build of my app I noticed a problem when using a context menu (from the Silverlight Toolkit for WP) - when the user taps & holds an item to bring up the context menu, this also changes the current selected item in the list.

    Now I'm not sure if it's really wrong that this happens but it would be good to have a possibility to prevent this behaviour as I think many apps react on selection changes in lists to start a navigation to a details page (or something like that).

    So a wish for the next release: please make it possible to have the DataBoundListBox only change it's selected item when the user makes a single tap, and not on a tap & hold.

    In the meantime i just listen to the open & closed events of the Context Menu so I always know when a context menu is open ... and in this case prevent changig the selected item.

    Btw, did I already mention that I'd really like to see a better performing, rockin' fluid context menu in your WP7 controls to replace the Silverlight Toolkit one? (hint, hint) :)

    Thanks,
    Bernhard


  2. Answer
    Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 11 Aug 2011 Link to this post

    Hi Bernhard,

    Thanks for writing and for your feedback.

    Indeed, the behavior that you describe is not correct. I have checked this behavior with the standard ListBox control and it seems that there is a certain time interval which, when passes, the ManipulationCompleted event that comes is not considered a tap event and thus the item in question is not selected.

    We will consider this and will make sure to sync RadDataBoundListBox to behave in pretty much the same way.

    As for implementing our own context menu - we have not discussed this yet and I cannot give any exact information on whether we are going to implement such component or not.

    I have updated your account with 500 Telerik points for your feedback on the ItemTap logic in RadDataBoundListBox.

    I hope this is helpful.

    Do not hesitate to get back to us in case you have further questions or need assistance.

    Greetings,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
  4. Bernhard König
    Bernhard König avatar
    78 posts
    Member since:
    Nov 2009

    Posted 11 Aug 2011 Link to this post

    Thanks Deyan!

    cheers,
    b.
  5. Garry
    Garry avatar
    1 posts
    Member since:
    Oct 2010

    Posted 11 Aug 2011 Link to this post

    So I'm having the same issue (was waiting for the response), but I dont see a work around for this behaviour. How can we prevent the click event firing so we dont trigger the navigation?
    Thanks
  6. Bernhard König
    Bernhard König avatar
    78 posts
    Member since:
    Nov 2009

    Posted 12 Aug 2011 Link to this post

    Hi Garry,

    you can't prevent the event from firing but rather write some code to work around it.

    I don't know if you're using MVVM for your project, but what I have done is:

     

    • Added a new boolean property "IsAnyContextMenuOpen" to my ViewModel
    • Added an event handler to Context Menu's Opened and Closed events in the code behind of my View
    • I keep a reference to my ViewModel in my View's code behind so I set the ViewModel.IsAnyContextMenuOpen property to true when the Opened event was raised and to false when the Closed event was raised.
    • In my ViewModel property that holds the selected item of the listbox ("ListboxSelectedItem" or something) i add code to the Setter that prevents setting a new value for this property as long as IsAnyContextMenuOpen is true.

    If you're not using MVVM it would be even easier, just keep a field or property that holds the boolean value in your code behind and prevent executing any code that should not run while this flag is true.

    That's not beautiful, but it works until we get a fix ...

    hth,
    Bernhard

Back to Top
DevCraft banner